|
jxUtil 0.6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.sourceforge.jxutil.IntRangesSet
A sorted set to store integers. This set is specialized on storing integer values which can be grouped into ranges. E.g. the set {1,2,3,4,5,11,12,13,30} is stored as {1,5,11,13,30,30}. The more ranges are in the set, the better the storage characteristics get, compared to an int[]. This set is always better as an corresponding TreeSet with Integer values.
| Field Summary | |
private boolean |
debug
|
private static int |
DEFAULTDELTA
|
private int |
delta
The delta to grow the set with. |
(package private) int |
length
The highest index that stores information+1 |
(package private) int[] |
set
The integers stored in groups of start,end values. |
(package private) long |
size
The cached number of elements in the set. |
| Constructor Summary | |
IntRangesSet()
Construct an empty IntRangesSet. |
|
IntRangesSet(int initialsize,
int delta)
Construct an empty IntRangesSet with given initial storage size and delta. |
|
| Method Summary | |
boolean |
add(int x)
Add an int to the set. |
boolean |
add(int[] ia)
|
boolean |
add(Object obj)
Add an Integer to the set. |
boolean |
addAll(Collection coll)
Add all Integers in given collection. |
boolean |
addRange(int from,
int to)
|
void |
clear()
Clear all elements of this set. |
Object |
clone()
Return a clone of this set. |
Comparator |
comparator()
Return null. |
IntRangesSet |
complement()
Return the complement of the set on the complete range of int. |
IntRangesSet |
complement(int min,
int max)
Return the complement of the set given the universe. |
boolean |
contains(int x)
Check if the set contains given int. |
boolean |
contains(Object obj)
Check whether the set contains given Integer. |
boolean |
containsAll(Collection coll)
Check whether the set contains given Integers. |
boolean |
equals(Object obj)
Check whether the set equals the given object. |
Object |
first()
Return the first element. |
SortedSet |
headSet(Object toElement)
Return a view... |
boolean |
isEmpty()
Test for emptyness. |
Iterator |
iterator()
Return an iterator over the elements. |
Object |
last()
Return the last element. |
long |
lsize()
Return the full size of the set. |
void |
pack()
Pack the array to contain only as much space as neccessary. |
boolean |
remove(int x)
Remove given int from the set. |
boolean |
remove(Object obj)
Remove given Integer from set. |
boolean |
removeAll(Collection coll)
Remove given Integers from set. |
boolean |
retainAll(Collection coll)
Retain given Integers. |
private int |
search(int x)
Find the index for a value. |
int |
size()
Return the number of elements in the set. |
SortedSet |
subSet(Object fromElement,
Object toElement)
Return a view. |
SortedSet |
tailSet(Object fromElement)
Return a view. |
Object[] |
toArray()
Return an array with the elements. |
Object[] |
toArray(Object[] ia)
Copy the elements into an array. |
int[] |
toIntArray()
Copy the sets elements into an int[]. |
String |
toString()
Format the set to a string. |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
hashCode |
| Field Detail |
private boolean debug
private static final int DEFAULTDELTA
private final int delta
int length
int[] set
long size
| Constructor Detail |
public IntRangesSet()
public IntRangesSet(int initialsize,
int delta)
| Method Detail |
public final boolean add(int x)
public final boolean add(int[] ia)
public final boolean add(Object obj)
throws NullPointerException,
ClassCastException
add in interface SetNullPointerException - - if the specified element is null
ClassCastException - - if the class of the specified element
is not Integer
public final boolean addAll(Collection coll)
throws ClassCastException
addAll in interface SetClassCastException - - if the class of some element of the
specified collection is not Integer, in this case no element is added.
public final boolean addRange(int from,
int to)
public final void clear()
clear in interface Setpublic final Object clone()
clone in class Objectpublic final Comparator comparator()
comparator in interface SortedSetpublic final IntRangesSet complement()
public final IntRangesSet complement(int min,
int max)
min - The start of the range.max - The end of the range.
public final boolean contains(int x)
public final boolean contains(Object obj)
throws ClassCastException
contains in interface SetClassCastException - - if the class of the specified element
is not Integerpublic final boolean containsAll(Collection coll)
containsAll in interface Setpublic final boolean equals(Object obj)
equals in interface Setequals in class Objectpublic final Object first()
first in interface SortedSet
public final SortedSet headSet(Object toElement)
throws ClassCastException
headSet in interface SortedSetClassCastException - - if the class of the specified element
is not Integerpublic final boolean isEmpty()
isEmpty in interface Setpublic final Iterator iterator()
iterator in interface Setpublic final Object last()
last in interface SortedSetpublic final long lsize()
public final void pack()
public final boolean remove(int x)
public final boolean remove(Object obj)
remove in interface Setpublic final boolean removeAll(Collection coll)
removeAll in interface Setpublic final boolean retainAll(Collection coll)
retainAll in interface Setprivate final int search(int x)
public final int size()
size in interface Set
public final SortedSet subSet(Object fromElement,
Object toElement)
throws ClassCastException
subSet in interface SortedSetClassCastException - - if the class of the specified elements
is not Integer
public final SortedSet tailSet(Object fromElement)
throws ClassCastException
tailSet in interface SortedSetClassCastException - - if the class of the specified element
is not Integerpublic final Object[] toArray()
toArray in interface Setpublic final Object[] toArray(Object[] ia)
toArray in interface Setpublic final int[] toIntArray()
public final String toString()
toString in class Object
|
jxUtil 0.6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||