Class CellHeap
Defined in File CellHeap.h
Nested Relationships
Nested Types
Class Documentation
-
class CellHeap
a heap of cells of two fields, with a mark-and-sweep collector
Public Types
-
using Value = long
a field: nil, an atom (atom( k ) for k >= 0) or a cell (its address)
Public Functions
-
explicit CellHeap(std::size_t n)
a heap of n cells, all free
- Pre:
n >= 1
-
Value cons(Value car, Value cdr)
a new cell with the fields car and cdr, after a collection if no cell is free
- Pre:
a cell is free after the collection
-
std::size_t collect(bool reversal = true)
marks the cells reachable from the roots, by pointer reversal or with a stack, and frees the others; the cells freed
- Post:
the cells freed are the unreachable ones, the fields of the others unchanged (an audit)
-
std::size_t freeCells(void) const
Public Static Functions
-
using Value = long