ch.javasoft.util.intcoll
Class BitSetIntSet

java.lang.Object
  extended by ch.javasoft.util.intcoll.AbstractIntCollection
      extended by ch.javasoft.util.intcoll.AbstractSortedIntSet
          extended by ch.javasoft.util.intcoll.BitSetIntSet
All Implemented Interfaces:
IntCollection, IntIterable, IntSet, SortedIntSet, Serializable, Cloneable, Iterable<Integer>, Collection<Integer>, Set<Integer>, SortedSet<Integer>

public class BitSetIntSet
extends AbstractSortedIntSet
implements Cloneable, Serializable

Implementation of IntSet, also implementing SortedSet, but with support limited to positive integers.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ch.javasoft.util.intcoll.AbstractIntCollection
mod
 
Constructor Summary
BitSetIntSet()
           
BitSetIntSet(BitSet bitSet)
           
BitSetIntSet(int[] values)
           
BitSetIntSet(IntSet set)
           
 
Method Summary
 boolean addInt(int value)
           
 void clear()
           
 BitSetIntSet clone()
           
 Comparator<? super Integer> comparator()
           
 boolean containsInt(int o)
           
 boolean equals(Object obj)
           
 int firstInt()
           
 IntIterator intIterator()
           
 boolean isEmpty()
           
 Iterator<Integer> iterator()
           
 int lastInt()
           
 boolean removeInt(int value)
           
 int size()
           
 BitSetIntSet subSet(int fromElement, int toElement)
          Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
protected
<T> T[]
toArrayInternal(T[] arr, boolean checkSize)
           
 BitSet toBitSet()
           
protected  int[] toIntArrayInternal(int[] arr, boolean checkSize)
           
 String toString()
           
 
Methods inherited from class ch.javasoft.util.intcoll.AbstractSortedIntSet
headSet, headSet, subSet, tailSet, tailSet
 
Methods inherited from class ch.javasoft.util.intcoll.AbstractIntCollection
add, addAll, addAll, addAll, contains, containsAll, first, hashCode, last, remove, removeAll, retainAll, toArray, toArray, toIntArray, toIntArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.javasoft.util.intcoll.IntCollection
addAll, addAll, toIntArray, toIntArray
 
Methods inherited from interface java.util.SortedSet
first, last
 
Methods inherited from interface java.util.Set
add, addAll, contains, containsAll, hashCode, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

BitSetIntSet

public BitSetIntSet()

BitSetIntSet

public BitSetIntSet(IntSet set)

BitSetIntSet

public BitSetIntSet(BitSet bitSet)

BitSetIntSet

public BitSetIntSet(int[] values)
Method Detail

toBitSet

public BitSet toBitSet()

size

public int size()
Specified by:
size in interface Collection<Integer>
Specified by:
size in interface Set<Integer>
Specified by:
size in class AbstractIntCollection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<Integer>
Specified by:
isEmpty in interface Set<Integer>
Overrides:
isEmpty in class AbstractIntCollection

containsInt

public boolean containsInt(int o)
Specified by:
containsInt in interface IntCollection
Overrides:
containsInt in class AbstractIntCollection

iterator

public Iterator<Integer> iterator()
Specified by:
iterator in interface Iterable<Integer>
Specified by:
iterator in interface Collection<Integer>
Specified by:
iterator in interface Set<Integer>
Overrides:
iterator in class AbstractIntCollection

toArrayInternal

protected <T> T[] toArrayInternal(T[] arr,
                                  boolean checkSize)
Overrides:
toArrayInternal in class AbstractIntCollection

clear

public void clear()
Specified by:
clear in interface Collection<Integer>
Specified by:
clear in interface Set<Integer>
Specified by:
clear in class AbstractIntCollection

addInt

public boolean addInt(int value)
Specified by:
addInt in interface IntCollection
Specified by:
addInt in class AbstractIntCollection

removeInt

public boolean removeInt(int value)
Specified by:
removeInt in interface IntCollection
Specified by:
removeInt in class AbstractIntCollection

intIterator

public IntIterator intIterator()
Specified by:
intIterator in interface IntCollection
Specified by:
intIterator in interface IntIterable
Specified by:
intIterator in class AbstractIntCollection

toIntArrayInternal

protected int[] toIntArrayInternal(int[] arr,
                                   boolean checkSize)
Overrides:
toIntArrayInternal in class AbstractIntCollection

comparator

public Comparator<? super Integer> comparator()
Specified by:
comparator in interface SortedSet<Integer>
Returns:
always null

firstInt

public int firstInt()
Overrides:
firstInt in class AbstractIntCollection

lastInt

public int lastInt()
Overrides:
lastInt in class AbstractIntCollection

subSet

public BitSetIntSet subSet(int fromElement,
                           int toElement)
Description copied from interface: SortedIntSet
Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Specified by:
subSet in interface SortedIntSet
Parameters:
fromElement - low endpoint (inclusive) of the returned set
toElement - high endpoint (exclusive) of the returned set
Returns:
a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

clone

public BitSetIntSet clone()
Overrides:
clone in class AbstractIntCollection

equals

public boolean equals(Object obj)
Specified by:
equals in interface Collection<Integer>
Specified by:
equals in interface Set<Integer>
Overrides:
equals in class AbstractSortedIntSet

toString

public String toString()
Overrides:
toString in class AbstractIntCollection