forked from utx201777/TinySTL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MySet.h
62 lines (60 loc) · 928 Bytes
/
MySet.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "SimpleAllocate.h"
#include "AVLTree.h"
#include "BSTree.h"
namespace TinySTL
{
template<class T>
class MySet
{
public:
typedef T value_type;
typedef AVLTree<T> tree_type;
typedef tree_type * tree_ptr;
typedef typename tree_type::iterator iterator;
typedef typename tree_type::size_type size_type;
protected:
tree_ptr tree;
public:
MySet()
{
tree = new tree_type();
}
~MySet()
{
delete tree;
}
size_type size()
{
return tree->size();
}
bool empty()
{
return tree->empty();
}
iterator begin()
{
return tree->begin();
}
iterator end()
{
return tree->end();
}
bool exist(value_type value)
{
return find(value) != end();
}
iterator find(value_type value)
{
return tree->find(value);
}
void erase(value_type value)
{
tree->erase(value);
}
void insert(value_type value)
{
tree->insert(value);
}
};
}