|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<Integer>
org.limewire.collection.SparseIntSet
public class SparseIntSet
Represents a set of distinct integers.
Like Set, SparseIntSet is not synchronized.
The integers in this set are sorted in ascending order. It would be nice for it to implement the SortedSet interface eventually.
Optimized to have compact representation when the set is "sparse". (For "dense" sets you should use IntSet.) Integers are stored as primitives, so you're guaranteed 4*N bytes of memory used after calling the compact() method.
All retrieval and insertion operations run in O(log n) time, where n is the size of the set.
This class is not thread-safe.
| Constructor Summary | |
|---|---|
SparseIntSet()
Creates an empty set with capacity = 8. |
|
SparseIntSet(Collection<? extends Integer> c)
Creates a set containing all the elements of the provided collection. |
|
SparseIntSet(int initialCapacity)
Creates an empty set with the provided initial capacity. |
|
| Method Summary | |
|---|---|
boolean |
add(Integer i)
|
boolean |
addAll(Collection<? extends Integer> c)
|
void |
compact()
Compacts this set to occupy 4*size() bytes of memory. |
boolean |
contains(Object o)
|
int |
getActualMemoryUsed()
|
Iterator<Integer> |
iterator()
|
int |
nextSetBit(int fromIndex)
|
boolean |
remove(Object o)
|
boolean |
retainAll(Collection<?> o)
|
int |
size()
|
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
clear, containsAll, isEmpty, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
clear, containsAll, isEmpty, toArray, toArray |
| Constructor Detail |
|---|
public SparseIntSet()
public SparseIntSet(int initialCapacity)
initialCapacity - the initial capacity desired.public SparseIntSet(Collection<? extends Integer> c)
| Method Detail |
|---|
public void compact()
public int getActualMemoryUsed()
public int nextSetBit(int fromIndex)
public boolean add(Integer i)
add in interface Collection<Integer>add in interface Set<Integer>add in class AbstractCollection<Integer>public boolean addAll(Collection<? extends Integer> c)
addAll in interface Collection<Integer>addAll in interface Set<Integer>addAll in class AbstractCollection<Integer>public boolean remove(Object o)
remove in interface Collection<Integer>remove in interface Set<Integer>remove in class AbstractCollection<Integer>public boolean contains(Object o)
contains in interface Collection<Integer>contains in interface Set<Integer>contains in class AbstractCollection<Integer>public Iterator<Integer> iterator()
iterator in interface Iterable<Integer>iterator in interface Collection<Integer>iterator in interface Set<Integer>iterator in class AbstractCollection<Integer>public int size()
size in interface Collection<Integer>size in interface Set<Integer>size in class AbstractCollection<Integer>public boolean retainAll(Collection<?> o)
retainAll in interface Collection<Integer>retainAll in interface Set<Integer>retainAll in class AbstractCollection<Integer>
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||