-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathBSTSet.java
45 lines (35 loc) · 972 Bytes
/
BSTSet.java
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
/***********************************************************
* @Description : 基于第六章的BST实现的集合(BSTSet)
* @author : 梁山广(Laing Shan Guang)
* @date : 2018/5/16 23:19
* @email : [email protected]
***********************************************************/
package Chapter07SetAndMap.Section1SetBasicAndBSTSet;
import Chapter06BST.BST;
public class BSTSet<E extends Comparable<E>> implements Set<E> {
private BST<E> bst;
public BSTSet() {
bst = new BST<>();
}
@Override
public void add(E e) {
bst.add(e);
}
@Override
public void delete(E e) {
bst.remove(e);
}
@Override
public boolean contain(E e) {
// 这里的e实际指地是key哈
return bst.contains(e);
}
@Override
public int getSize() {
return bst.getSize();
}
@Override
public boolean isEmpty() {
return bst.isEmpty();
}
}