本文整理汇总了C++中SplayTree::constructor方法的典型用法代码示例。如果您正苦于以下问题:C++ SplayTree::constructor方法的具体用法?C++ SplayTree::constructor怎么用?C++ SplayTree::constructor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplayTree
的用法示例。
在下文中一共展示了SplayTree::constructor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_remove
void test_remove(){
MyAllocator allocator;
allocator.constructor(1000);
SplayTree<int,int> a;
a.constructor(&allocator);
for(int k=0;k<100;k++){
a.insert(k);
assert(a.find(k)!=NULL);
}
assert(a.size()==100);
a.remove(9);
assert(a.size()==99);
assert(a.find(9)==NULL);
a.remove(50);
assert(a.size()==98);
assert(a.find(50)==NULL);
a.remove(50);
assert(a.size()==98);
assert(a.find(50)==NULL);
a.remove(-1);
assert(a.size()==98);
}
示例2: test_iterator
void test_iterator(){
MyAllocator allocator;
allocator.constructor(1000);
SplayTree<int,int> a;
a.constructor(&allocator);
SplayTreeIterator<int,int> b;
b.constructor(&a);
b.hasNext();
b.hasNext();
b.hasNext();
b.next();
a.insert(1);
b.constructor(&a);
b.hasNext();
b.hasNext();
b.hasNext();
b.next();
b.hasNext();
b.hasNext();
}
示例3: main
int main(){
MyAllocator allocator;
allocator.constructor(1000);
SplayTree<int,int> lol;
lol.constructor(&allocator);
srand(time(NULL));
int n=10000000;
int k=n;
while(k--){
lol.insert(k);
}
int i=0;
SplayTreeIterator<int,int> iterator(&lol);
while(iterator.hasNext()){
SplayNode<int,int>*node=iterator.next();
int v=node->getKey();
i++;
}
lol.freeze();
assert(i==n);
assert(n==lol.size());
SplayTreeIterator<int,int> iterator2(&lol);
i=0;
while(iterator2.hasNext()){
SplayNode<int,int>*node=iterator2.next();
int v=node->getKey();
i++;
}
assert(i==n);
assert(n==lol.size());
test_remove();
test_iterator();
return 0;
}