public class IntSet
extends java.lang.Object
implements java.util.Set<java.lang.Integer>
| Modifier and Type | Field and Description |
|---|---|
protected int |
addIndex
Index pointing to an empty position.
|
protected int[] |
data
Holds the integers
|
protected java.util.BitSet |
isThere
Tells whether the int is there
|
protected int |
lastIndex
Last index that contains a value
|
protected int |
numElements
Number of integers in data
|
protected int |
pollIndex
Index that can be polled next.
|
| Constructor and Description |
|---|
IntSet()
Creates a new IntSet
|
IntSet(java.util.BitSet copy)
Creates a new IntSet by copying the given bit set
|
IntSet(int capacity)
Creates a new IntSet with an initial capacity
|
IntSet(IntSet copy)
Creates a new IntSet by copying the given set
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int v)
Adds the element
|
boolean |
add(java.lang.Integer e)
Adds the element
|
boolean |
add(long i)
Adds this element
|
boolean |
add(java.lang.Number e)
Adds this element
|
boolean |
addAll(java.util.BitSet s)
Adds all elements
|
boolean |
addAll(java.util.Collection<? extends java.lang.Integer> c)
Adds all elements
|
boolean |
addAll(IntSet s)
Adds all elements
|
void |
addTo(java.util.BitSet s)
Adds all elements of this set to s
|
void |
clear()
Removes all elements
|
void |
clear(int capacity) |
boolean |
contains(int i)
TRUE if the set contains i
|
boolean |
contains(long i)
TRUE if the set contains i
|
boolean |
contains(java.lang.Object o)
TRUE if the set contains o
|
boolean |
containsAll(java.util.Collection<?> c)
TRUE if the set contains all elements of c
|
IntSet |
enhancedBy(int addMe)
Adds addMe, returns THIS
|
IntSet |
enhancedBy(IntSet addMe)
Adds all elements, returns THIS
|
protected int |
indexOf(int v)
Finds the element, sets addIndex to a free position
|
boolean |
isEmpty()
TRUE if the set is empty
|
PeekIterator<java.lang.Integer> |
iterator() |
static void |
main(java.lang.String[] args)
Test method
|
static IntSet |
of(int... initial)
Creates a new IntSet from initial values.
|
int |
poll() |
boolean |
remove(int i)
Removes one element, returns TRUE if the set was modified
|
boolean |
remove(long i)
Removes one element, returns TRUE if the set was modified
|
boolean |
remove(java.lang.Object o)
Removes one element (has to be a number), returns TRUE if the set was modified
|
boolean |
removeAll(java.util.BitSet s)
Removes all elements of s from this set
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all elements in c
|
boolean |
removeAll(IntSet c)
Removes all elements in c
|
protected int |
removeIndex(int index)
Removes an item
|
boolean |
retainAll(java.util.Collection<?> c)
Removes all elements that are not in c
|
void |
setTo(IntSet copy)
Overwrites the current IntSet with the given one
|
protected void |
shrink()
Deletes empty space if necessary
|
IntSet |
shrunkBy(int addMe)
Removes the given element, returns THIS
|
IntSet |
shrunkBy(IntSet addMe)
Removes the given elements, returns THIS
|
int |
size() |
java.lang.Object[] |
toArray()
Returns an array of the elements of this set
|
<T> T[] |
toArray(T[] a)
Not supported
|
java.lang.String |
toString() |
protected int[] data
protected java.util.BitSet isThere
protected int numElements
protected int pollIndex
protected int addIndex
protected int lastIndex
public IntSet(IntSet copy)
public IntSet(java.util.BitSet copy)
public IntSet()
public IntSet(int capacity)
public PeekIterator<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>public boolean add(int v)
public void clear(int capacity)
public int poll()
protected int indexOf(int v)
protected void shrink()
protected int removeIndex(int index)
public static IntSet of(int... initial)
public void setTo(IntSet copy)
public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<java.lang.Integer>retainAll in interface java.util.Set<java.lang.Integer>public boolean remove(int i)
public boolean remove(long i)
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>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<java.lang.Integer>removeAll in interface java.util.Set<java.lang.Integer>public boolean removeAll(IntSet c)
public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.Set<java.lang.Integer>public <T> T[] toArray(T[] a)
toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.Set<java.lang.Integer>public java.lang.String toString()
toString in class java.lang.Objectpublic int size()
size in interface java.util.Collection<java.lang.Integer>size in interface java.util.Set<java.lang.Integer>public boolean add(long i)
public boolean add(java.lang.Number e)
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>public boolean addAll(IntSet s)
public boolean addAll(java.util.BitSet s)
public boolean removeAll(java.util.BitSet s)
public void addTo(java.util.BitSet s)
public IntSet enhancedBy(int addMe)
public IntSet shrunkBy(int addMe)
public boolean contains(int i)
public boolean contains(long i)
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>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<java.lang.Integer>containsAll in interface java.util.Set<java.lang.Integer>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Integer>isEmpty in interface java.util.Set<java.lang.Integer>public void clear()
clear in interface java.util.Collection<java.lang.Integer>clear in interface java.util.Set<java.lang.Integer>public boolean add(java.lang.Integer e)
add in interface java.util.Collection<java.lang.Integer>add in interface java.util.Set<java.lang.Integer>public static void main(java.lang.String[] args)