Hi,I have to support an old project based on pure MDL. This code uses AVL Tree API even if not fully documented.
I need to change the simpler tree key with a more complex one and this is why I should replace mdlAvlTree_init with mdlAvlTree_initExtended.But no documentation and no examples exist about mdlAvlTree_initExtended.
I just find the api signature below but the use of blockSize and signature arguments is not clear.
AvlTree *mdlAvlTree_initExtended(int keyType,int (*compareFunc)(),int blockSize,int signature);
I did few tests, setting blockSize argument to my key size (or even more) , but my code aborts with a "System fault 5" after the second mdlAvlTree_insertNode.
Did anybody ever use this function ? If so, can anybody explain how to use mdlAvlTree_initExtended or post an example ?
Thanks,
Marco
seen it, was just some overlapping between my mail and yours. From what I can say so far I don't see any failure (function signature cor compare is even correct according to the .h file). 3 suggestions nevertheless, just for a test or alternativ. 1. might be you should provide a function for traversal even. I'm not sure (without documentation) if you just don't need to provide all 3 callbacks (compare, traverse, delete) for full functionality. 2. I would try to make the compare function Public, not sure about the access level here, but it's a while since dealing with pure mdl ;) 3. As an alternative couldn't you prepare the key to contain a mix of both values (ie. printf("%s %ld", key1, key2)) if the order is such simple as you showed us (using preceeding zeroes wiht fixed lenght l for the int number) ? And than use the standard version mdlAvlTree_init(AVLKEY_PSTRING) instead of the extended ! HTH Michael
mdlAvlTree_initExtended is expecting a native compare func, it's not doing any of the boiler plate stuff to call out to mdl which is why it's not working for you.
Hi,
you are right!
I made the comparatorFunc native (I moved it in a .dll) and now mdlAvlTree_insertNode doesn't throw any SYSTEM FAULT.
Thanks for your hint.
Unknown said: I agree with you about STL but in this pure MDL module I can't directly use STL
Unknown said:I made the comparatorFunc native (I moved it in a .dll)
So you're writing native code! Why not use C++ and the STL?
Regards, Jon Summers LA Solutions