# AdaptiveLru

from pandac.PandaModules import AdaptiveLru

Class : AdaptiveLru
Description : A basic LRU-type algorithm, except that it is adaptive and attempts to avoid evicting pages that have been used more frequently (even if less recently) than other pages.
The interface is designed to be identical to that for SimpleLru, so that it may be used as a drop-in replacement.

## Inheritance:

AdaptiveLru: Namable
Namable:

## Methods of AdaptiveLru:

AdaptiveLru (Constructor)
beginEpoch
considerEvict
countActiveSize
evictTo
getMaxSize
getMaxUpdatesPerFrame
getTotalSize
getWeight
output
setMaxSize
setMaxUpdatesPerFrame
setWeight
validate
write

## Methods of Namable:

Namable (Constructor)
clearName
getClassType
getName
hasName
operator =
output
setName

AdaptiveLru AdaptiveLru::AdaptiveLru(string const &name, unsigned int max_size); Description:

beginEpoch void AdaptiveLru::begin_epoch(void); Description: Marks the end of the previous epoch and the beginning of the next one. This will evict any objects that are pending eviction, and also update any internal bookkeeping.

considerEvict void AdaptiveLru::consider_evict(void); Description: Evicts a sequence of objects if the queue is full.

countActiveSize unsigned int AdaptiveLru::count_active_size(void) const; Description: Returns the total size of the pages that were enqueued since the last call to begin_epoch().

evictTo void AdaptiveLru::evict_to(unsigned int target_size); Description: Evicts a sequence of objects until the queue fits within the indicated target size, regardless of its normal max size.

getMaxSize unsigned int AdaptiveLru::get_max_size(void) const; Description: Returns the max size of all objects that are allowed to be active on the LRU.

getMaxUpdatesPerFrame int AdaptiveLru::get_max_updates_per_frame(void) const; Description: Returns the maximum number of pages the AdaptiveLru will update each frame.

getTotalSize unsigned int AdaptiveLru::get_total_size(void) const; Description: Returns the total size of all objects currently active on the LRU.

getWeight float AdaptiveLru::get_weight(void) const; The following methods are specific to AdaptiveLru, and do not exist in the SimpleLru implementation. In most cases, the defaults will be sufficient, so you do not need to mess with them. Description: Returns the weight value used to compute the exponential moving average.

output void AdaptiveLru::output(ostream &out) const; Description:

setMaxSize void AdaptiveLru::set_max_size(unsigned int max_size); Description: Changes the max size of all objects that are allowed to be active on the LRU. If the size is (size_t)-1, there is no limit.

setMaxUpdatesPerFrame void AdaptiveLru::set_max_updates_per_frame(int max_updates_per_frame); Description: Specifies the maximum number of pages the AdaptiveLru will update each frame. This is a performance optimization: keeping this number low limits the impact of the AdaptiveLru's adaptive algorithm.

setWeight void AdaptiveLru::set_weight(float weight); The following methods are specific to AdaptiveLru, and do not exist in the SimpleLru implementation. In most cases, the defaults will be sufficient, so you do not need to mess with them. Description: Specifies the weight value used to compute the exponential moving average.

validate bool AdaptiveLru::validate(void); Description: Checks that the LRU is internally self-consistent. Returns true if successful, false if there is some problem.

write void AdaptiveLru::write(ostream &out, int indent_level) const; Description:

Namable Namable::Namable(string const &initial_name = ("")); Description:

clearName void Namable::clear_name(void); Description: Resets the Namable's name to empty.

getClassType static TypeHandle Namable::get_class_type(void); Undocumented function.

getName string const &Namable::get_name(void) const; Description:

hasName bool Namable::has_name(void) const; Description: Returns true if the Namable has a nonempty name set, false if the name is empty.

operator = Namable &Namable::operator =(Namable const &other); Description:

output void Namable::output(ostream &out) const; In the absence of any definition to the contrary, outputting a Namable will write out its name. Description: Outputs the Namable. This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

setName void Namable::set_name(string const &name); Description: