beautypg.com

HP Integrity NonStop J-Series User Manual

Page 92

background image

fm.Read(next); // 3

DiskNode n;
while (next != RWNIL) { // 4
fm.SeekTo(next); // 5
fm.Read(n.data); // 6
fm.Read(n.nextNode);
cout << n.data << "\n"; // 7
next = n.nextNode; // 8
}
return 0;
} // 9

And this is a line-by-line description of the program:

//1 The

RWFileManager

has been constructed with an old File.

//2 The member function start() returns the offset to the first space ever allocated in the file. In

this case, that space will contain an offset to the start of the linked-list.

//3 Read the offset to the first link.

//4 A loop to read through the linked-list and print each entry.

//5 Seek to the next link.

//6 Read the next link.

//7 Print the integer.

//8 Get the offset to the next link.

//9 The destructor for class

RWFileManager

, which closes the file, will be called here.

This manual is related to the following products: