|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.collection.IntSet
public class IntSet
Represents a set of distinct integers.
Like Set, IntSet is not synchronized.
Optimized to have an extremely compact representation when the set is "dense", i.e., has many sequential elements. For example {1, 2} and {1, 2, ..., 1000} require the same amount of space. All retrieval operations run in O(log n) time, where n is the size of the set. Insertion operations may be slower.
All methods have the same specification as the Set class, except
that values are restricted to int' for the reason described above. For
this reason, methods are not specified below.
This class is not thread-safe.
IntSet s = new IntSet(10);
s.add(1); s.add(1);
s.add(3); s.add(4); s.add(5);
s.add(7);
System.out.println("Set is " + s);
s.add(2);
System.out.println("Set is " + s);
s.remove(3);
System.out.println("Set is " + s);
Output:
Set is [1, 3-5, 7]
Set is [1-5, 7]
Set is [1-2, 4-5, 7]
| Nested Class Summary | |
|---|---|
class |
IntSet.IntSetIterator
Yields a sequence of int's (not Object's) in order, without removal support. |
| Constructor Summary | |
|---|---|
IntSet()
|
|
IntSet(int expectedSize)
|
|
| Method Summary | |
|---|---|
boolean |
add(int x)
|
boolean |
addAll(IntSet s)
|
void |
clear()
|
boolean |
contains(int x)
|
IntSet.IntSetIterator |
iterator()
Returns the values of this in order from lowest to highest, as int. |
int |
max()
|
int |
min()
|
boolean |
remove(int x)
|
protected void |
repOk()
Checks rep invariant. |
boolean |
retainAll(IntSet s)
|
int |
size()
|
String |
toString()
|
void |
trim()
Ensures that this consumes the minimum amount of memory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IntSet()
public IntSet(int expectedSize)
| Method Detail |
|---|
protected void repOk()
public int max()
public int min()
public int size()
public void clear()
public boolean contains(int x)
public boolean add(int x)
public boolean remove(int x)
public boolean addAll(IntSet s)
public boolean retainAll(IntSet s)
public void trim()
public IntSet.IntSetIterator iterator()
public String toString()
toString in class Object
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||