B-Tree index of delimited file

Anyone have any ideas on creating a B-Tree index of a delimited text file in memory? I'm trying to code this in C++ (no C functions - OO only).

Example:
void create(char datafile[], int delimiter);
Will create a B-Tree from the datafile passed to the function, and use the Xth delimited field of the file as the B-Tree's primary key, where X = dilimiter.

Any ideas?? Thanks.

Last edited by neolyn; 11-23-2004 at 07:18 PM.
Reason: Made this a question.

To implement B-Trees in memory is somewhat difficult. Simply inserting the keys into the tree, similar to a binary tree, isn't too hard. Just makes sure a node's children are ordered such as the pictures on the website. The hard part ist when the key is inserted to a node and some condition is met on the node you need to split the node, increasing the keys in the level above. Once spliting the node inserted, the level above might also meet the split condition, so your split routine has to recursively walk above the trees. In effect, from a child node you need to acess a parent node, and your datastructure would look something like this:

The ordering between keys and the nodes are such that keys[0] < keys[1] <...< keys[numKeys-1], and, ignoring a few special cases, nodes[i] is placed between key[i - 1] and key[i].

How you split is that you take a group keys such as ( 2, 5, 6, 7, 8, 9, 10), and then pick the median. After picking the medien, you form two sides, those before the medien and those after. In this case the medien is 7, so your two sides are (2, 5, 6) and (8, 9, 10). The 7 must, then, be brought up to the layer above the node splitted, and then this node might be split. As you can see it's fairly complicated; you're definitely going want to try this on paper a few times.