|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthealpix.essentials.RangeSet
public class RangeSet
Class for dealing with sets of integer ranges. Ranges are described by the first element and the one-past-last element. This code was inspired by Jan Kotek's "LongRangeSet" class, but has been completely reimplemented.
Nested Class Summary | |
---|---|
static interface |
RangeSet.ValueIterator
Interface describing an iterator for going through all values in a RangeSet object. |
Constructor Summary | |
---|---|
RangeSet()
Construct new object with space for 8 entries (4 ranges). |
|
RangeSet(int cap)
Construct new object with a given initial number of entries. |
|
RangeSet(long[] data)
Construct new object from an array of longs. |
|
RangeSet(RangeSet other)
Construct new object from another RangeSet |
Method Summary | |
---|---|
void |
add(long a,
long b)
After this operation, the RangeSet contains the union of itself and [a;b[. |
void |
append(long val)
Append a single-value range to the object. |
void |
append(long a,
long b)
Append a range to the object. |
void |
append(RangeSet other)
Append an entire range set to the object. |
void |
checkConsistency()
Checks the object for internal consistency. |
void |
clear()
Remove all entries in the set. |
boolean |
contains(long a)
Returns true if a is contained in the set, else false. |
boolean |
containsAll(long a,
long b)
Returns true if all numbers [a;b[ are contained in the set, else false. |
boolean |
containsAll(RangeSet other)
Returns true if the set completely contains "other", else false. |
boolean |
containsAny(long a,
long b)
Returns true if any of the numbers [a;b[ are contained in the set, else false. |
boolean |
containsAny(RangeSet other)
Returns true if there is overlap between the set and "other", else false. |
RangeSet |
difference(RangeSet other)
After this operation, the RangeSet contains the difference of itself and other. |
void |
ensureCapacity(int cap)
Make sure the object can hold at least the given number of entries. |
boolean |
equals(Object obj)
Returns true the object represents an identical set of ranges as obj. |
int |
hashCode()
|
void |
intersect(long a,
long b)
After this operation, the RangeSet contains the intersection of itself and [a;b[. |
RangeSet |
intersection(RangeSet other)
After this operation, the RangeSet contains the intersection of itself and other. |
boolean |
isEmpty()
|
long |
ivbegin(int iv)
|
long |
ivend(int iv)
|
long |
nval()
|
void |
readExternal(ObjectInput in)
|
void |
remove(long a,
long b)
After this operation, the RangeSet contains the difference of itself and [a;b[. |
void |
setTo(RangeSet other)
|
void |
setToDifference(RangeSet a,
RangeSet b)
After this operation, the RangeSet contains the difference of RangeSets a and b. |
void |
setToIntersection(RangeSet a,
RangeSet b)
After this operation, the RangeSet contains the intersection of RangeSets a and b. |
void |
setToUnion(RangeSet a,
RangeSet b)
After this operation, the RangeSet contains the union of RangeSets a and b. |
int |
size()
|
long[] |
toArray()
Creates an array cointainig all the numbers in the RangeSet. |
String |
toString()
|
void |
trimSize()
Shrinks the array for the entries to minimum size. |
RangeSet |
union(RangeSet other)
After this operation, the RangeSet contains the union of itself and other. |
RangeSet.ValueIterator |
valueIterator()
Returns a ValueIterator, which iterates over all individual numbers in the RangeSet. |
void |
writeExternal(ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RangeSet()
public RangeSet(int cap)
cap
- number of initially reserved entries.public RangeSet(long[] data)
data
- public RangeSet(RangeSet other)
other
- Method Detail |
---|
public void setTo(RangeSet other)
public void checkConsistency()
public void ensureCapacity(int cap)
public void trimSize()
public void append(long val)
val
- value to appendpublic void append(long a, long b)
a
- first long in rangeb
- one-after-last long in rangepublic void append(RangeSet other)
public int size()
public boolean isEmpty()
public long ivbegin(int iv)
public long ivend(int iv)
public void clear()
public void setToUnion(RangeSet a, RangeSet b)
public void setToIntersection(RangeSet a, RangeSet b)
public void setToDifference(RangeSet a, RangeSet b)
public RangeSet union(RangeSet other)
public RangeSet intersection(RangeSet other)
public RangeSet difference(RangeSet other)
public boolean contains(long a)
public boolean containsAll(long a, long b)
public boolean containsAny(long a, long b)
public boolean containsAll(RangeSet other)
public boolean containsAny(RangeSet other)
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public long nval()
public void intersect(long a, long b)
public void add(long a, long b)
public void remove(long a, long b)
public long[] toArray()
public String toString()
toString
in class Object
public RangeSet.ValueIterator valueIterator()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
|
"Built from revision exported" | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |