forked from liang-liang-gao/STL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmySet.h
More file actions
34 lines (32 loc) · 709 Bytes
/
mySet.h
File metadata and controls
34 lines (32 loc) · 709 Bytes
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
#ifndef MYSET_H
#define MYSET_H
#include "RB_tree.h"
#include "RB_tree.cpp"
template<class Key>
class mySet
{
private:
RB_tree<Key, Key> rbt;//set内部的红黑树
public:
typedef typename RB_tree<Key, Key>::iterator iterator;//告诉编译器iterator是一种类型
iterator begin() {
return rbt.begin();
}
iterator end() {
return rbt.end();
}
iterator find(const Key& key) {
//iterator it = rbt.find(key);
return rbt.find(key);
}
bool insert(const Key& key) {
return rbt.insert(key, key);
}
bool erase(const Key& key) {
return rbt.erase(key);
}
int size() {
return rbt.getSize();
}
};
#endif