home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ User's Journal & Wi…eveloper's Journal Tools
/
C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso
/
windbase
/
memslcpp.3
/
tavltre2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-04
|
20KB
|
446 lines
/***************************************************************************\
** **
** WW WW IIIIIIII NNN NN DDDDDDD BBBBBBB AA SSSSSS EEEEEEEE **
** WW W WW II NNNN NN DD DD BB BB AA AA SS EE **
** WW W WW II NN NN NN DD DD BBBBBBB AAAAAAAA SSSSSS EEEEEE **
** WW W WW II NN NNNN DD DD BB BB AA AA SS EE **
** WWWWW IIIIIIII NN NNN DDDDDDD BBBBBBB AA AA SSSSSS EEEEEEEE **
** **
** SSSSSS OOOOOO FFFFFFFF TTTTTTTT WW WW AA RRRRRRR EEEEEEEE **
** SS OO OO FF TT WW W WW AA AA RR RR EE **
** SSSSS OO OO FFFFF TT WW W WW AAAAAAAA RRRRRRR EEEEEE **
** SS OO OO FF TT WW W WW AA AA RR RR EE **
** SSSSSS OOOOOO FF TT WWWWW AA AA RR RR EEEEEEEE **
** **
********** NOTICE ***********************************************************
** This file contains valuable trade secrets and proprietary **
** assets of Windbase Software Inc. Embodying substantial **
** creative efforts and confidential information. Unauthorized **
** use, copying, decompiling, translating, disclosure or **
** transfer, of any kind, is strictly prohibited. **
** **
** COPYRIGHT (C) 1992, 1993, 1994, 1995. Windbase Software Inc. **
** ALL RIGHTS RESERVED. **
\***************************************************************************/
/*
** AVL Balanced Threaded Binary Tree - Non Templates Version
*/
int Compare(void *nullitem, char *item1, char *item2)
{
nullitem = nullitem;
if (item1 == NULL || item2 == NULL)
{
cout << "Compare: null value. Aborting...\n";
exit(1);
}
return(strcmp(item1,item2));
}
void Print(void *nullitem, char *item)
{
nullitem = nullitem;
if (item)
cout << "Execute: " << item << "\n";
else
cout << "Execute: null value\n";
}
main()
{
WBTAVLTree tree;
char *strptr;
int i;
tree.SetCompare(NULL,(int (*)(void *, void *, void *))Compare);
tree.SetExecute(NULL,(void (*)(void *, void *))Print);
for (i = 0; i < 5; i++)
{
cout << "====================================================\n";
tree += "Item00";
tree += "Item01";
tree += "Item02";
tree += "Item03";
tree += "Item04";
tree += "Item05";
tree += "Item06";
tree += "Item07";
tree += "Item08";
tree += "Item09";
tree.Add("Item10");
tree.Add("Item11");
tree.Add("Item12");
tree.Add("Item13");
tree.Add("Item14");
tree.Add("Item15");
tree.Add("Item16");
tree.Add("Item17");
tree.Add("Item18");
tree.Add("Item19");
tree.Add("Item20");
tree.Add("Item21");
tree.Add("Item22");
tree.Add("Item23");
tree.Add("Item24");
tree.Add("Item25");
tree.Add("Item26");
tree.Add("Item27");
tree.Add("Item28");
tree.Add("Item29");
tree.Add("Item30");
tree.Add("Item31");
tree.Add("Item32");
tree.Add("Item33");
tree.Add("Item34");
tree.Add("Item35");
tree.Add("Item36");
tree.Add("Item37");
tree.Add("Item38");
tree.Add("Item39");
tree.Add("Item40");
tree.Add("Item41");
tree.Add("Item42");
tree.Add("Item43");
tree.Add("Item44");
tree.Add("Item45");
tree.Add("Item46");
tree.Add("Item47");
tree.Add("Item48");
tree.Add("Item49");
tree.Add("Item50");
tree.Add("Item51");
tree.Add("Item52");
tree.Add("Item53");
tree.Add("Item54");
tree.Add("Item55");
tree.Add("Item56");
tree.Add("Item57");
tree.Add("Item58");
tree.Add("Item59");
tree.Add("Item60");
tree.Add("Item61");
tree.Add("Item62");
tree.Add("Item63");
tree.Add("Item64");
tree.Add("Item65");
tree.Add("Item66");
tree.Add("Item67");
tree.Add("Item68");
tree.Add("Item69");
tree.Add("Item70");
tree.Add("Item71");
tree.Add("Item72");
tree.Add("Item73");
tree.Add("Item74");
tree.Add("Item75");
tree.Add("Item76");
tree.Add("Item77");
tree.Add("Item78");
tree.Add("Item79");
tree.Add("Item80");
tree.Add("Item81");
tree.Add("Item82");
tree.Add("Item83");
tree.Add("Item84");
tree.Add("Item85");
tree.Add("Item86");
tree.Add("Item87");
tree.Add("Item88");
tree.Add("Item89");
tree.Add("Item90");
tree.Add("Item91");
tree.Add("Item92");
tree.Add("Item93");
tree.Add("Item94");
tree.Add("Item95");
tree.Add("Item96");
tree.Add("Item97");
tree.Add("Item98");
tree.Add("Item99");
tree.Add("Item00");
tree.Add("Item01");
tree.Add("Item02");
tree.Add("Item03");
tree.Add("Item04");
tree.Add("Item05");
tree.Add("Item06");
tree.Add("Item07");
tree.Add("Item08");
tree.Add("Item09");
tree.Add("Item00");
tree.Add("Item01");
tree.Add("Item02");
tree.Add("Item03");
tree.Add("Item04");
tree.Add("Item05");
tree.Add("Item06");
tree.Add("Item07");
tree.Add("Item08");
tree.Add("Item09");
tree += "Item100";
tree += "Item101";
tree += "Item102";
tree += "Item103";
tree += "Item104";
tree += "Item105";
tree += "Item106";
tree += "Item107";
tree += "Item108";
tree.Execute();
cout << "GetLast(): " << (char *) tree.GetLast() << "\n";
cout << "GetFirst(): " << (char *) tree.GetFirst() << "\n";
while ((strptr = (char *) tree.GetNext()) != NULL)
cout << "GetNext(): " << strptr << "\n";
while ((strptr = (char *) tree.GetPrevious()) != NULL)
cout << "GetPrevious(): " << strptr << "\n";
while ((strptr = (char *) tree++) != NULL)
cout << "tree++: " << strptr << "\n";
while ((strptr = (char *) tree--) != NULL)
cout << "tree--: " << strptr << "\n";
strptr = (char *) tree.GetFirst();
while ((strptr = (char *) tree.GetGreater(strptr)) != NULL)
cout << "GetGreater(): " << strptr << "\n";
strptr = (char *) tree.GetLast();
while ((strptr = (char *) tree.GetLess(strptr)) != NULL)
cout << "GetLess(): " << strptr << "\n";
cout << "GetLess(): " << (char *) tree.GetLess("Item01") << "\n";
while ((strptr = (char *) tree--) != NULL)
cout << "tree--: " << strptr << "\n";
cout << "GetGreater(): " << (char *) tree.GetGreater("Item01") << "\n";
while ((strptr = (char *) tree++) != NULL)
cout << "tree++: " << strptr << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item00") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item01") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item02") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item03") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item04") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item05") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item06") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item07") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item08") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item09") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item10") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item11") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item12") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item13") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item14") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item15") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item16") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item17") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item18") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item19") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item20") << "\n";
cout << "GetEqual(): " << (char *) tree.GetEqual("Item21"