I'm working on some very general code for BB-Trees. Right now the programmer includes a function that compares the objects that the tree sorts. This is a simple matter for numbers and strings, but other objects are left up to the programmer. I wanted to improve the node delete algorithm, but then the programer would have to provide an average function as well for their object, I guess having two delete algorithms would be okay. How do you quantitively compare two strings to find an average? I've tried to comment the code to make it very readable. And I'll have examples for numbers and strings, but it could be used on any thing. What about saving the tree data to disk? Maybe the programmer writes the routine to save/load a node object and I save/load the node structure? Oh, and memmory management. Should the programmer have to define the alocation of node objects, and I just manager the tree nodes? I guess I'm really tring to figure out where to draw the line and contain the code. Thanks, bitRAKE This message was edited by bitRAKE, on 3/23/2001 6:15:39 PM
BitRake, What funcationality you wrap basically depends on how the user will use it (and how you feel you want to implement it). If you want to provide the Dynamic Memory Management, go for it. It would be appreciated by many. The few who would rather manage memory themselves, well, you can't make everyone happy, or in this case, you can... provide two implementations of the algorithm. I'm doing some algorithms, also. My approach is include the memory management in the library. It would be useless for me to provide a linked list impementation or two and make the programmer have to perform memory management themselves. For that matter, they may as well write their won. This bring a point: if the programmer is okay with a generic implementation, then manage memory automatically. If it's specialize, it shouldn't be hard to provide a way to allow them to still use the algorithm and yet provide their own memory management. I like the idea of having the implementation do the work for me. I write all my code like that. Because the point of using prebuilt code is to not write it yourself. The curse of using prebuilt code is that you might have to write it yourself, anyway. _Shawn
I get confused because I usually write something for my own use and it's easy for me to plug the code in here or there with other stuff. Guess I just have to assume it's the same for everyone else, but it's nice to design stuff with a larger scope than my own use. bitRAKE
I haven't seen any BB-Tree x86 source on the web. Must be hard to find or something. I know someone must have wrote it. bitRAKE
Hi. I needed to *read* Clipper NTX files from my C++ applications, and for this reason I wrote a DLL in win32asm that implements some functions to find the first and the subsequent records for any given key. I can send the source code to programmers interested in. Now I would like to *write* Clipper NTX files, i.e. adding recno/key pairs. But I know it is not that easy, because the binary tree should be kept balanced when adding keys. Can anyone suggest me some theoretical articles to read about maintaining binary trees balanced ? Thanks from Alvise.