forked from patmorin/ods
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSet.java
More file actions
86 lines (76 loc) · 2.18 KB
/
SSet.java
File metadata and controls
86 lines (76 loc) · 2.18 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package ods;
import java.util.Comparator;
import java.util.Iterator;
/**
* The SSet<T> interface is a simple interface that allows a class to implement
* all the functionality of the (more complicated) SortedSet<T> interface. Any
* class that implements SSet<T> can be wrapped in a SortedSSet<T> to obtain an
* implementation of SortedSet<T>
*
* @author morin
*
* @param <T>
* @see SortedSSet<T>
*/
public interface SSet<T> extends Iterable<T> {
/**
* @return the comparator used by this SSet
*/
public Comparator<? super T> comparator();
/**
* @return the number of elements in this SSet
*/
public int size();
/**
* Find the smallest element in the SSet that is greater than or equal to x.
*
* @param x
* @return the smallest element in the SSet that is greater than or equal to
* x or null if no such element exists
*/
public T find(T x);
/**
* Find the smallest element in the SSet that is greater than or equal to x.
* If x is null, return the smallest element in the SSet
*
* @param x
* @return the smallest element in the SSet that is greater than or equal to
* x or null if no such element exists. If x is null then the
* smallest element in the SSet
*/
public T findGE(T x);
/**
* Find the largest element in the SSet that is greater than to x. If x is
* null, return the largest element in the SSet
*
* @param x
* @return the largest element in the SSet that is less than x. If x is null
* then the smallest element in the SSet
*/
public T findLT(T x);
/**
* Add the element x to the SSet
*
* @param x
* @return true if the element was added or false if x was already in the
* set
*/
public boolean add(T x);
/**
* Remove the element x from the SSet
*
* @param x
* @return true if x was removed and false if x was not removed (because x
* was not present)
*/
public boolean remove(T x);
/**
* Clear the SSet, removing all elements from the set
*/
public void clear();
/**
* Return an iterator that iterates over the elements in sorted order,
* starting at the first element that is greater than or equal to x.
*/
public Iterator<T> iterator(T x);
}