bug fix
This commit is contained in:
@@ -93,7 +93,7 @@ namespace TinySTL{
|
|||||||
const T *ptr_;
|
const T *ptr_;
|
||||||
cntrPtr container_;
|
cntrPtr container_;
|
||||||
stack<const T *> parent_;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>root<6F><74>ptr_<72>ĸ<EFBFBD><C4B8>ڵ<EFBFBD><DAB5><EFBFBD>·<EFBFBD><C2B7>
|
stack<const T *> parent_;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>root<6F><74>ptr_<72>ĸ<EFBFBD><C4B8>ڵ<EFBFBD><DAB5><EFBFBD>·<EFBFBD><C2B7>
|
||||||
std::set<const T *> rvisited_;//<2F><>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<C7B7><F1B1BBB7>ʹ<EFBFBD>
|
//std::set<const T *> rvisited_;//<2F><>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<C7B7><F1B1BBB7>ʹ<EFBFBD>
|
||||||
std::set<const T *> visited_;//<2F><>ǰ<EFBFBD>ڵ<EFBFBD><DAB5>Ƿ<C7B7><F1B1BBB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>
|
std::set<const T *> visited_;//<2F><>ǰ<EFBFBD>ڵ<EFBFBD><DAB5>Ƿ<C7B7><F1B1BBB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>
|
||||||
public:
|
public:
|
||||||
bst_iter(const T *ptr, cntrPtr container);
|
bst_iter(const T *ptr, cntrPtr container);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace TinySTL{
|
|||||||
while (temp && temp != ptr_ && temp->data_ != ptr_->data_){
|
while (temp && temp != ptr_ && temp->data_ != ptr_->data_){
|
||||||
parent_.push(temp);
|
parent_.push(temp);
|
||||||
if (temp->data_ < ptr_->data_){
|
if (temp->data_ < ptr_->data_){
|
||||||
|
//temp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>temoָ<6F><D6B8><EFBFBD>ĸ<EFBFBD><C4B8>ڵ㲻<DAB5><E3B2BB>Ҫ<EFBFBD>ٴη<D9B4><CEB7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
visited_.insert(temp);//add 2015.01.14
|
||||||
temp = temp->right_;
|
temp = temp->right_;
|
||||||
}
|
}
|
||||||
else if (temp->data_ > ptr_->data_){
|
else if (temp->data_ > ptr_->data_){
|
||||||
@@ -23,37 +25,25 @@ namespace TinySTL{
|
|||||||
bst_iter<T>& bst_iter<T>::operator ++(){
|
bst_iter<T>& bst_iter<T>::operator ++(){
|
||||||
visited_.insert(ptr_);//<2F><>node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
visited_.insert(ptr_);//<2F><>node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
if (ptr_->right_){//<2F><>node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if (ptr_->right_){//<2F><>node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
rvisited_.insert(ptr_);
|
//rvisited_.insert(ptr_);
|
||||||
parent_.push(ptr_);
|
parent_.push(ptr_);
|
||||||
ptr_ = ptr_->right_;
|
ptr_ = ptr_->right_;
|
||||||
while (ptr_ && ptr_->left_){
|
while (ptr_ && ptr_->left_){
|
||||||
parent_.push(ptr_);
|
parent_.push(ptr_);
|
||||||
ptr_ = ptr_->left_;
|
ptr_ = ptr_->left_;
|
||||||
}
|
}
|
||||||
}
|
}else{//node<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>ڵ<F2B8B8BD>·<EFBFBD><C2B7><EFBFBD>ƶ<EFBFBD>
|
||||||
else{//node<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
ptr_ = 0;//add 2015.01.14
|
||||||
|
|
||||||
while (!parent_.empty()){
|
while (!parent_.empty()){
|
||||||
ptr_ = parent_.top();
|
ptr_ = parent_.top();
|
||||||
parent_.pop();
|
parent_.pop();
|
||||||
if (visited_.count(ptr_) == 0){//<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
if (visited_.count(ptr_) == 0){//<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>,<2C><>ʱptr_ָ<5F><D6B8><EFBFBD>˽ڵ<CBBD>
|
||||||
visited_.insert(ptr_);
|
visited_.insert(ptr_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (rvisited_.count(ptr_) == 0){//<2F><><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
ptr_ = 0;//<2F><>Ϊ<EFBFBD>ڱ<EFBFBD>
|
||||||
rvisited_.insert(ptr_);
|
}//end of while
|
||||||
if (ptr_->right_){
|
}//end of if
|
||||||
parent_.push(ptr_);
|
|
||||||
ptr_ = ptr_->right_;
|
|
||||||
while (ptr_ && ptr_->left_){
|
|
||||||
parent_.push(ptr_);
|
|
||||||
ptr_ = ptr_->left_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ptr_ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace TinySTL{
|
|||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
|
|
||||||
for (auto i = 0; i != 10; ++i){
|
for (auto i = 0; i != 100; ++i){
|
||||||
auto r = rd() % 65536;
|
auto r = rd() % 65536;
|
||||||
bst.insert(r);
|
bst.insert(r);
|
||||||
v.push_back(r);
|
v.push_back(r);
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ namespace TinySTL{
|
|||||||
template<class T>
|
template<class T>
|
||||||
using tsBst = TinySTL::binary_search_tree < T > ;
|
using tsBst = TinySTL::binary_search_tree < T > ;
|
||||||
|
|
||||||
|
void testCase1();
|
||||||
|
void testCase2();
|
||||||
|
void testCase3();
|
||||||
|
void testCase4();
|
||||||
|
|
||||||
void testAllCases();
|
void testAllCases();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,13 +79,16 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Alloc.cpp" />
|
<ClCompile Include="Detail\Alloc.cpp" />
|
||||||
|
<ClCompile Include="Detail\String.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="Profiler\Profiler.cpp" />
|
<ClCompile Include="Profiler\Profiler.cpp" />
|
||||||
<ClCompile Include="String.cpp" />
|
|
||||||
<ClCompile Include="Test\AlgorithmTest.cpp" />
|
<ClCompile Include="Test\AlgorithmTest.cpp" />
|
||||||
|
<ClCompile Include="Test\BinarySearchTreeTest.cpp" />
|
||||||
<ClCompile Include="Test\BitmapTest.cpp" />
|
<ClCompile Include="Test\BitmapTest.cpp" />
|
||||||
<ClCompile Include="Test\CircularBufferTest.cpp" />
|
<ClCompile Include="Test\CircularBufferTest.cpp" />
|
||||||
|
<ClCompile Include="Test\DequeTest.cpp" />
|
||||||
|
<ClCompile Include="Test\ListTest.cpp" />
|
||||||
<ClCompile Include="Test\PairTest.cpp" />
|
<ClCompile Include="Test\PairTest.cpp" />
|
||||||
<ClCompile Include="Test\PriorityQueueTest.cpp" />
|
<ClCompile Include="Test\PriorityQueueTest.cpp" />
|
||||||
<ClCompile Include="Test\QueueTest.cpp" />
|
<ClCompile Include="Test\QueueTest.cpp" />
|
||||||
@@ -104,6 +107,12 @@
|
|||||||
<ClInclude Include="CircularBuffer.h" />
|
<ClInclude Include="CircularBuffer.h" />
|
||||||
<ClInclude Include="Construct.h" />
|
<ClInclude Include="Construct.h" />
|
||||||
<ClInclude Include="Deque.h" />
|
<ClInclude Include="Deque.h" />
|
||||||
|
<ClInclude Include="Detail\BinarySearchTree.impl.h" />
|
||||||
|
<ClInclude Include="Detail\Bitmap.impl.h" />
|
||||||
|
<ClInclude Include="Detail\CircularBuffer.impl.h" />
|
||||||
|
<ClInclude Include="Detail\Deque.impl.h" />
|
||||||
|
<ClInclude Include="Detail\List.impl.h" />
|
||||||
|
<ClInclude Include="Detail\Vector.impl.h" />
|
||||||
<ClInclude Include="Functional.h" />
|
<ClInclude Include="Functional.h" />
|
||||||
<ClInclude Include="Iterator.h" />
|
<ClInclude Include="Iterator.h" />
|
||||||
<ClInclude Include="List.h" />
|
<ClInclude Include="List.h" />
|
||||||
@@ -114,8 +123,11 @@
|
|||||||
<ClInclude Include="String.h" />
|
<ClInclude Include="String.h" />
|
||||||
<ClInclude Include="SuffixArray.h" />
|
<ClInclude Include="SuffixArray.h" />
|
||||||
<ClInclude Include="Test\AlgorithmTest.h" />
|
<ClInclude Include="Test\AlgorithmTest.h" />
|
||||||
|
<ClInclude Include="Test\BinarySearchTreeTest.h" />
|
||||||
<ClInclude Include="Test\BitmapTest.h" />
|
<ClInclude Include="Test\BitmapTest.h" />
|
||||||
<ClInclude Include="Test\CircularBufferTest.h" />
|
<ClInclude Include="Test\CircularBufferTest.h" />
|
||||||
|
<ClInclude Include="Test\DequeTest.h" />
|
||||||
|
<ClInclude Include="Test\ListTest.h" />
|
||||||
<ClInclude Include="Test\PairTest.h" />
|
<ClInclude Include="Test\PairTest.h" />
|
||||||
<ClInclude Include="Test\PriorityQueueTest.h" />
|
<ClInclude Include="Test\PriorityQueueTest.h" />
|
||||||
<ClInclude Include="Test\QueueTest.h" />
|
<ClInclude Include="Test\QueueTest.h" />
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
<Filter Include="ScreenShots">
|
<Filter Include="ScreenShots">
|
||||||
<UniqueIdentifier>{f20d9032-1c1d-424a-a8aa-f39c87789d3b}</UniqueIdentifier>
|
<UniqueIdentifier>{f20d9032-1c1d-424a-a8aa-f39c87789d3b}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Detail">
|
||||||
|
<UniqueIdentifier>{7dd5c5f0-33b6-44c6-b2b9-d4c0ec1d4c13}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Profiler\Profiler.cpp">
|
<ClCompile Include="Profiler\Profiler.cpp">
|
||||||
@@ -60,11 +63,20 @@
|
|||||||
<ClCompile Include="Test\CircularBufferTest.cpp">
|
<ClCompile Include="Test\CircularBufferTest.cpp">
|
||||||
<Filter>Test</Filter>
|
<Filter>Test</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Alloc.cpp">
|
<ClCompile Include="Test\DequeTest.cpp">
|
||||||
<Filter>头文件</Filter>
|
<Filter>Test</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="String.cpp">
|
<ClCompile Include="Test\ListTest.cpp">
|
||||||
<Filter>头文件</Filter>
|
<Filter>Test</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Detail\Alloc.cpp">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Detail\String.cpp">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Test\BinarySearchTreeTest.cpp">
|
||||||
|
<Filter>Test</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -167,6 +179,33 @@
|
|||||||
<ClInclude Include="Test\CircularBufferTest.h">
|
<ClInclude Include="Test\CircularBufferTest.h">
|
||||||
<Filter>Test</Filter>
|
<Filter>Test</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Test\DequeTest.h">
|
||||||
|
<Filter>Test</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Test\ListTest.h">
|
||||||
|
<Filter>Test</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Detail\Deque.impl.h">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Detail\Bitmap.impl.h">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Detail\CircularBuffer.impl.h">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Detail\Vector.impl.h">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Detail\List.impl.h">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Test\BinarySearchTreeTest.h">
|
||||||
|
<Filter>Test</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Detail\BinarySearchTree.impl.h">
|
||||||
|
<Filter>Detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\README.md" />
|
<None Include="..\README.md" />
|
||||||
|
|||||||
Reference in New Issue
Block a user