Tools.h++ Manual

21-98 104011 Tandem Computers Incorporated
21
RWDiskPageHeap
RWDiskPageHeap
|
RWBufferedPageHeap
|
RWVirtualPageHeap
Synopsis
#include <rw/diskpage.h>
unsigned nbufs;
unsigned pagesize;
RWDiskPageHeap heap("filename", nbufs, pagesize);
Description Class
RWDiskPageHeap
is a specializing type of buffered page heap. It swaps
its pages to disk as necessary.
Example In this example, 100 nodes of a linked list are created and strung together. The
list is then walked, confirming that it contains 100 nodes. Each node is a single
page. The "pointer" to the next node is actually the handle for the next page.
Code Example 21-2
#include <rw/diskpage.h>
#include <rw/rstream.h>
struct Node {
int key;
RWHandle next;
};
RWHandle head = 0;
const int N = 100; // Exercise 100 Nodes
main() {
// Construct a disk-based page heap with page size equal
// to the size of Node and with 10 buffers:
RWDiskPageHeap heap(0, 10, sizeof(Node));
// Build the linked list:
for (int i=0; i; i++){