Example – HP Integrity NonStop J-Series User Manual
Page 96

Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
Example
In this example, key-value pairs of character strings and offsets to
RWDate
s representing
birthdays are stored. Given a name, you can retrieve a birthdate from disk.
#include
#include
#include
#include
#include
main(){
RWCString name;
RWDate birthday;
RWFileManager fm("birthday.dat");
RWBTreeOnDisk btree(fm); // 1
while (cin >> name) // 2
{
cin >> birthday; // 3
RWoffset loc = fm.allocate(birthday.binaryStoreSize());// 4
fm.SeekTo(loc); // 5
fm << birthday; // 6
btree.insertKeyAndValue(name, loc); // 7
}
return 0;
}
Here's the line-by-line description:
//1 Construct a B-tree. The default constructor is used, resulting in a key length of 16
characters.
//2 Read the name from standard input. This loop will exit when EOF is reached.
//3 Read the corresponding birthday.