Tools.h++ Manual
21-194 104011 Tandem Computers Incorporated
21
Example This example illustrates adding N nodes to a linked list. In this linked list, a
"pointer" to the next node is actually a handle.
Public constructor
RWVirtualPageHeap(unsigned pgsize);
Sets the size of a page.
Public destructor
virtual ~RWVirtualPageHeap();
The destructor has been made virtual to give specializing classes a chance to
deallocate any resources that they may have allocated.
Public member functions
unsigned pageSize() const;
Returns the page size for this abstract page heap.
#include <rw/vpage.h>
struct Node {
int key;
RWHandle next;
};
RWHandle head = 0;
void addNodes(RWVirtualPageHeap& heap, unsigned N) {
for (unsigned i=0; i<N; i++){
RWHandle h = heap.allocate();
Node* newNode = (Node*)heap.lock(h);
newNode->key = i;
newNode->next = head;
head = h;
heap.dirty(h);
heap.unlock(h);
}
}