Discussions related to Visual Prolog
User avatar
drspro2
VIP Member
Posts: 115
Joined: 28 Apr 2006 12:03

question about collections RedBlack trees

Post by drspro2 »

if I understand it well that if you want to create an indexed collection you should use the class redblack tree.

In Vp5 there was the btree in the class chain-db.

Is there a standardised way or a preferable way to save a complete RedBlack tree to a file and read it into memory again afterwards?

so that in this way you could load a redblacktree from file into memory , update this tree , for example insert an entry, and then save it back to the file. Would this be a good way to build databases? you could use the redblack tree for example to store indexes with associated values , and these values could point to file-positions of (large) records in other files.

In the redblack class -help file i couldnt find anything like this. or do i completely misunderstand the purpose of the redblack tree.
User avatar
drspro2
VIP Member
Posts: 115
Joined: 28 Apr 2006 12:03

Re: question about collections RedBlack trees

Post by drspro2 »

ok i think i might understand it, if you would want to do this you should use redblack get indexes_nd, save them to a text file , and when you want to reload the index you re-create the redblack tree from the textfile with insertkey. but then you might as well store your indexes by just appending them in an index- text- file ( not sorted ) which is very fast, and when needed you load the whole text file in the redblack tree in memory and use it from there to be able to search fast. Its a pity that you cant update the redblack tree directly in a file on disk directly with minimum file access