yage.core.freelist
Authors:
Eric Poggel
License:
LGPL v3
- class FreeList
(T);
- A class to allow fast allocations / de-allocations, using
a free list. This can be several times faster than new and delete.
Inherit from this class and instantiate it as the same type as the
class it's used in.
Example:
class Node : FreeList!(Node)
{ ...
}
Node a = Node.allocate(); // Pull from the freelist if available or allocate a new one if not.
Node.free(a); // a is placed on the global freelist ready for the next allocation.
- T allocate
();
- Used to quickly allocate
a new type T. Note that the values of the new type T will contain
memory garbage and needs to be set.
- void free
(T[] args...);
- Place one or more type T back on a free
list for the next allocation.
|