1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| template<class T> void ThreadTree<T>::CreateInThread() { ThreadNode<T>* pre = nullptr; if (root != nullptr) { createInThread(root, pre); pre->rightChild = nullptr; pre->rtag = 1; } }
template <class T> void ThreadTree<T>::createInThread(ThreadNode<T>* current, ThreadNode<T>* &pre) { if (current == NULL) return; createInThread(current->leftChild, pre); if (current->leftChild == NULL) { current->leftChild = pre; current->ltag = 1; } if (pre != NULL && pre->rightChild == NULL) { pre->rightChild = current; pre->rtag = 1; } pre = current; createInThread(current->rightChild, pre); }
|