Category : C++ Source Code
Archive   : JCOOL01.ZIP
Filename : BINARY_N.C
// Copyright (C) 1991 Texas Instruments Incorporated.
//
// Permission is granted to any individual or institution to use, copy, modify,
// and distribute this software, provided that this complete copyright and
// permission notice is maintained, intact, in all copies and supporting
// documentation.
//
// Texas Instruments Incorporated provides this software "as is" without
// express or implied warranty.
//
#include
// CoolBinary_Node -- Simple constructor to initialize a node object
// Input: None
// Output: None
template
CoolBinary_Node
}
// CoolBinary_Node -- constructor to initialize a node object and assign a value
// to the data slot
// Input: Data slot value
// Output: None
template
CoolBinary_Node
this->data = value; // Assign data value
}
// CoolBinary_Node -- Copy constructor to copy node and all subnodes
// Input: Binary node reference
// Output: Binary node reference
template
CoolBinary_Node
this->ltree = this->copy_nodes(bn.get_ltree()); // copy left tree
this->rtree = this->copy_nodes(bn.get_rtree()); // copy right tree
this->avl_balance = bn.avl_balance; // copy avl balance
this->data = bn.data; // copy data at this node
}
// ~CoolBinary_Node -- Destructor must be virtual
// Input: None
// Output: None
template
CoolBinary_Node
// operator= -- Assignment with another binary node, with recursive deep copy.
// Input: reference to node
// Ouput: mutated *this
template
CoolBinary_Node
delete this->ltree; // free old subnodes
delete this->rtree;
this->ltree = copy_nodes (n.get_ltree()); // Copy the left tree
this->rtree = copy_nodes (n.get_rtree()); // Copy the right tree
this->avl_balance = n.avl_balance; // Copy avl balance
this->data = n.data; // Copy value at node
return *this;
}
// copy_nodes -- Copies this node and all its subnodes
// Input: pointer to node to be copied
// Output: pointer to new copy of node with all new subnodes.
template
CoolBinary_Node
if (n == NULL)
return NULL;
CoolBinary_Node
new_n->ltree = copy_nodes (n->get_ltree()); // Copy the left tree
new_n->rtree = copy_nodes (n->get_rtree()); // Copy the right tree
new_n->data = n->data; // Copy the value
new_n->avl_balance = n->avl_balance; // Copy avl balance
return new_n; // Return copied node.
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/