public class IntSet extends Object implements Set<Integer>
| Modifier and Type | Field and Description |
|---|---|
protected int |
addIndex
Index pointing to an empty position.
|
protected int[] |
data
Holds the integers
|
protected 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(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(Integer e)
Adds the element
|
boolean |
add(long i)
Adds this element
|
boolean |
add(Number e)
Adds this element
|
boolean |
addAll(BitSet s)
Adds all elements
|
boolean |
addAll(Collection<? extends Integer> c)
Adds all elements
|
boolean |
addAll(IntSet s)
Adds all elements
|
void |
addTo(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(Object o)
TRUE if the set contains o
|
boolean |
containsAll(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<Integer> |
iterator() |
static void |
main(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(Object o)
Removes one element (has to be a number), returns TRUE if the set was modified
|
boolean |
removeAll(BitSet s)
Removes all elements of s from this set
|
boolean |
removeAll(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(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() |
Object[] |
toArray()
Returns an array of the elements of this set
|
<T> T[] |
toArray(T[] a)
Not supported
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCode, spliteratorparallelStream, removeIf, streamprotected int[] data
protected BitSet isThere
protected int numElements
protected int pollIndex
protected int addIndex
protected int lastIndex
public IntSet(IntSet copy)
public IntSet(BitSet copy)
public IntSet()
public IntSet(int capacity)
public PeekIterator<Integer> iterator()
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(Collection<?> c)
public boolean remove(int i)
public boolean remove(long i)
public boolean remove(Object o)
public boolean removeAll(Collection<?> c)
public boolean removeAll(IntSet c)
public Object[] toArray()
public <T> T[] toArray(T[] a)
public int size()
public boolean add(long i)
public boolean add(Number e)
public boolean addAll(Collection<? extends Integer> c)
public boolean addAll(IntSet s)
public boolean addAll(BitSet s)
public boolean removeAll(BitSet s)
public void addTo(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(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<Integer>containsAll in interface Set<Integer>public boolean isEmpty()
public void clear()
public boolean add(Integer e)
public static void main(String[] args)
Copyright © 2018. All rights reserved.