|
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<java.lang.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(java.util.Collection<? extends java.lang.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(java.lang.Integer i)
|
boolean |
addAll(java.util.Collection<? extends java.lang.Integer> c)
|
void |
compact()
Compacts this set to occupy 4*size() bytes of memory. |
boolean |
contains(java.lang.Object o)
|
int |
getActualMemoryUsed()
|
java.util.Iterator<java.lang.Integer> |
iterator()
|
int |
nextSetBit(int fromIndex)
|
boolean |
remove(java.lang.Object o)
|
boolean |
retainAll(java.util.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(java.util.Collection<? extends java.lang.Integer> c)
| Method Detail |
|---|
public void compact()
public int getActualMemoryUsed()
public int nextSetBit(int fromIndex)
public boolean add(java.lang.Integer i)
add in interface java.util.Collection<java.lang.Integer>add in interface java.util.Set<java.lang.Integer>add in class java.util.AbstractCollection<java.lang.Integer>public boolean addAll(java.util.Collection<? extends java.lang.Integer> c)
addAll in interface java.util.Collection<java.lang.Integer>addAll in interface java.util.Set<java.lang.Integer>addAll in class java.util.AbstractCollection<java.lang.Integer>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<java.lang.Integer>remove in interface java.util.Set<java.lang.Integer>remove in class java.util.AbstractCollection<java.lang.Integer>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<java.lang.Integer>contains in interface java.util.Set<java.lang.Integer>contains in class java.util.AbstractCollection<java.lang.Integer>public java.util.Iterator<java.lang.Integer> iterator()
iterator in interface java.lang.Iterable<java.lang.Integer>iterator in interface java.util.Collection<java.lang.Integer>iterator in interface java.util.Set<java.lang.Integer>iterator in class java.util.AbstractCollection<java.lang.Integer>public int size()
size in interface java.util.Collection<java.lang.Integer>size in interface java.util.Set<java.lang.Integer>size in class java.util.AbstractCollection<java.lang.Integer>public boolean retainAll(java.util.Collection<?> o)
retainAll in interface java.util.Collection<java.lang.Integer>retainAll in interface java.util.Set<java.lang.Integer>retainAll in class java.util.AbstractCollection<java.lang.Integer>
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||