This commit is contained in:
邹晓航
2014-11-29 16:15:26 +08:00
parent facdca2970
commit 6be63f791c
2 changed files with 6 additions and 4 deletions

View File

@@ -144,9 +144,10 @@ namespace TinySTL{
void binary_search_tree<T>::insert_elem(const T& val, node *&ptr){//<2F>ظ<EFBFBD><D8B8><EFBFBD>Ԫ<EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD>
if (ptr == 0){
ptr = nodeAllocator::allocate();
memset(ptr, 0, sizeof(node));
ptr->data_ = val;
//ptr->left_ = ptr->right_ = 0;
construct(&(ptr->data_, val));
/*memset(ptr, 0, sizeof(node));
ptr->data_ = val;*/
ptr->left_ = ptr->right_ = 0;
++size_;
}
else{

View File

@@ -154,7 +154,8 @@ namespace TinySTL{
nodePtr newNode(const T& val = T()){
nodePtr res = nodeAllocator::allocate();
res->container = this;
res->data = val;
//res->data = val; -> bug
construct(&(res->data), val);//fix
res->prev = nullptr;
res->next = nullptr;
return res;