链表栈,一个stacktop指针,一个int,每一个节点的指针指向的都是上一个的节点,由stacktop = new chainnode(element,stacktop)决定
链队列,一个queuefront指针,一个queueback指针,一个int
跳表
float cutOff;// used to decide level numberintlevel()const;// generate a random level numberint levels;// max current nonempty chainint dSize;// number of pairs in dictionaryint maxLevel;// max permissible chain level
K tailKey;// a large key
skipNode<K,E>*search(const K&)const;// search saving last nodes seen
skipNode<K,E>* headerNode;// header node pointer
skipNode<K,E>* tailNode;// tail node pointer
skipNode<K,E>** last;// last[i] = last node seen on level i
链式哈希表
protected:
sortedChain<K, E>* table;// hash table
hash<K> hash;// maps type K to nonnegative integerint dSize;// number of elements in listint divisor;// hash function divisor
链式二叉树
template<classE>classlinkedBinaryTree:publicbinaryTree<binaryTreeNode<E>>{public:linkedBinaryTree(){ root =NULL; treeSize =0;}~linkedBinaryTree(){erase();};boolempty()const{return treeSize ==0;}intsize()const{return treeSize;}
E*rootElement()const;voidmakeTree(const E& element,
linkedBinaryTree<E>&, linkedBinaryTree<E>&);
linkedBinaryTree<E>&removeLeftSubtree();
linkedBinaryTree<E>&removeRightSubtree();voidpreOrder(void(*theVisit)(binaryTreeNode<E>*)){
visit = theVisit;preOrder(root);}voidinOrder(void(*theVisit)(binaryTreeNode<E>*)){
visit = theVisit;inOrder(root);}voidpostOrder(void(*theVisit)(binaryTreeNode<E>*)){
visit = theVisit;postOrder(root);}voidlevelOrder(void(*)(binaryTreeNode<E>*));voidpreOrderOutput(){preOrder(output); cout << endl;}voidinOrderOutput(){inOrder(output); cout << endl;}voidpostOrderOutput(){postOrder(output); cout << endl;}voidlevelOrderOutput(){levelOrder(output); cout << endl;}voiderase(){postOrder(dispose);
root =NULL;
treeSize =0;}intheight()const{returnheight(root);}protected:
binaryTreeNode<E>*root;// pointer to rootint treeSize;// number of nodes in treestaticvoid(*visit)(binaryTreeNode<E>*);// visit functionstaticint count;// used to count nodes in a subtreestaticvoidpreOrder(binaryTreeNode<E>*t);staticvoidinOrder(binaryTreeNode<E>*t);staticvoidpostOrder(binaryTreeNode<E>*t);staticvoidcountNodes(binaryTreeNode<E>*t){
visit = addToCount;
count =0;preOrder(t);}staticvoiddispose(binaryTreeNode<E>*t){delete t;}staticvoidoutput(binaryTreeNode<E>*t){
cout << t->element <<' ';}staticvoidaddToCount(binaryTreeNode<E>*t){
count++;}staticintheight(binaryTreeNode<E>*t);};
// the following should work but gives an internal compiler error// template <class E> void (*linkedBinaryTree<E>::visit)(binaryTreeNode<E>*);// so the explicit declarations that follow are used for our purpose insteadvoid(*linkedBinaryTree<int>::visit)(binaryTreeNode<int>*);void(*linkedBinaryTree<booster>::visit)(binaryTreeNode<booster>*);void(*linkedBinaryTree<pair<int,int>>::visit)(binaryTreeNode<pair<int,int>>*);void(*linkedBinaryTree<pair<constint,char>>::visit)(binaryTreeNode<pair<constint,char>>*);void(*linkedBinaryTree<pair<constint,int>>::visit)(binaryTreeNode<pair<constint,int>>*);