bug fix
This commit is contained in:
@@ -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>
|
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){
|
if (ptr == 0){
|
||||||
ptr = nodeAllocator::allocate();
|
ptr = nodeAllocator::allocate();
|
||||||
memset(ptr, 0, sizeof(node));
|
construct(&(ptr->data_, val));
|
||||||
ptr->data_ = val;
|
/*memset(ptr, 0, sizeof(node));
|
||||||
//ptr->left_ = ptr->right_ = 0;
|
ptr->data_ = val;*/
|
||||||
|
ptr->left_ = ptr->right_ = 0;
|
||||||
++size_;
|
++size_;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -154,7 +154,8 @@ namespace TinySTL{
|
|||||||
nodePtr newNode(const T& val = T()){
|
nodePtr newNode(const T& val = T()){
|
||||||
nodePtr res = nodeAllocator::allocate();
|
nodePtr res = nodeAllocator::allocate();
|
||||||
res->container = this;
|
res->container = this;
|
||||||
res->data = val;
|
//res->data = val; -> bug
|
||||||
|
construct(&(res->data), val);//fix
|
||||||
res->prev = nullptr;
|
res->prev = nullptr;
|
||||||
res->next = nullptr;
|
res->next = nullptr;
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user