Package healpix.essentials
Class RangeSet
java.lang.Object
healpix.essentials.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.
- Author:
- Martin Reinecke
- Copyright:
- 2011-2015 Max-Planck-Society
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceInterface describing an iterator for going through all values in a RangeSet object.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(long a) After this operation, the RangeSet contains the union of itself and [a;a+1[.voidadd(long a, long b) After this operation, the RangeSet contains the union of itself and [a;b[.voidappend(long val) Append a single-value range to the object.voidappend(long a, long b) Append a range to the object.voidAppend an entire range set to the object.voidChecks the object for internal consistency.voidclear()Remove all entries in the set.booleancontains(long a) Returns true if a is contained in the set, else false.booleancontains(long a, long b) Returns true if all numbers [a;b[ are contained in the set, else false.booleanReturns true if the set completely contains "other", else false.booleancontainsAll(long a, long b) Deprecated.booleancontainsAll(RangeSet other) Deprecated.booleancontainsAny(long a, long b) Deprecated.booleancontainsAny(RangeSet other) Deprecated.difference(RangeSet other) Return the difference of this RangeSet and other.voidensureCapacity(int cap) Make sure the object can hold at least the given number of entries.booleanReturns true the object represents an identical set of ranges as obj.static RangeSetfromArray(long[] v) static RangeSetfromCompressed(byte[] data) Returns a RangeSet obtained by decompressing a byte array which was originally generated by toCompressed().inthashCode()voidintersect(long a, long b) After this operation, the RangeSet contains the intersection of itself and [a;b[.intersection(RangeSet other) Return the intersection of this RangeSet and other.booleanisEmpty()longivbegin(int iv) longivend(int iv) intnranges()longnval()booleanoverlaps(long a, long b) Returns true if any of the numbers [a;b[ are contained in the set, else false.booleanReturns true if there is overlap between the set and "other", else false.voidremove(long a) After this operation, the RangeSet contains the difference of itself and [a;a+1[.voidremove(long a, long b) After this operation, the RangeSet contains the difference of itself and [a;b[.long[]toArray()Creates an array containing all the numbers in the RangeSet.byte[]Returns a compressed representation of the RangeSet, using interpolative coding.toString()voidShrinks the array for the entries to minimum size, if it is more than twice the minimum sizevoidtrimSize()Shrinks the array for the entries to minimum size.Return the union of this RangeSet and other.Returns a ValueIterator, which iterates over all individual numbers in the RangeSet.
- 
Field Details- 
rprotected long[] rSorted list of interval boundaries.
- 
szprotected int szCurrent number of active entries.
 
- 
- 
Constructor Details- 
RangeSetpublic RangeSet()Construct new object with initial space for 4 ranges.
- 
RangeSetpublic RangeSet(int cap) Construct new object with initial capacity for a given number of ranges.- Parameters:
- cap- number of initially reserved ranges.
 
- 
RangeSetpublic RangeSet(long[] data) Construct new object from an array of longs.- Parameters:
- data-
 
- 
RangeSetConstruct new object from another RangeSet- Parameters:
- other-
 
 
- 
- 
Method Details- 
checkConsistencypublic void checkConsistency()Checks the object for internal consistency. If a problem is detected, an IllegalArgumentException is thrown.
- 
ensureCapacitypublic void ensureCapacity(int cap) Make sure the object can hold at least the given number of entries.
- 
trimSizepublic void trimSize()Shrinks the array for the entries to minimum size.
- 
trimIfTooLargepublic void trimIfTooLarge()Shrinks the array for the entries to minimum size, if it is more than twice the minimum size
- 
appendpublic void append(long val) Append a single-value range to the object.- Parameters:
- val- value to append
 
- 
appendpublic void append(long a, long b) Append a range to the object.- Parameters:
- a- first long in range
- b- one-after-last long in range
 
- 
appendAppend an entire range set to the object.
- 
nrangespublic int nranges()- Returns:
- number of ranges in the set.
 
- 
isEmptypublic boolean isEmpty()- Returns:
- true if no entries are stored, else false.
 
- 
ivbeginpublic long ivbegin(int iv) - Returns:
- first number in range iv.
 
- 
ivendpublic long ivend(int iv) - Returns:
- one-past-last number in range iv.
 
- 
clearpublic void clear()Remove all entries in the set.
- 
unionReturn the union of this RangeSet and other.
- 
intersectionReturn the intersection of this RangeSet and other.
- 
differenceReturn the difference of this RangeSet and other.
- 
containspublic boolean contains(long a) Returns true if a is contained in the set, else false.
- 
containspublic boolean contains(long a, long b) Returns true if all numbers [a;b[ are contained in the set, else false.
- 
containsAllDeprecated.
- 
overlapspublic boolean overlaps(long a, long b) Returns true if any of the numbers [a;b[ are contained in the set, else false.
- 
containsAnyDeprecated.
- 
containsReturns true if the set completely contains "other", else false.
- 
containsAllDeprecated.
- 
overlapsReturns true if there is overlap between the set and "other", else false.
- 
containsAnyDeprecated.
- 
equalsReturns true the object represents an identical set of ranges as obj.
- 
hashCodepublic int hashCode()
- 
nvalpublic long nval()- Returns:
- total number of values (not ranges) in the set.
 
- 
intersectpublic void intersect(long a, long b) After this operation, the RangeSet contains the intersection of itself and [a;b[.
- 
addpublic void add(long a, long b) After this operation, the RangeSet contains the union of itself and [a;b[.
- 
addpublic void add(long a) After this operation, the RangeSet contains the union of itself and [a;a+1[.
- 
removepublic void remove(long a, long b) After this operation, the RangeSet contains the difference of itself and [a;b[.
- 
removepublic void remove(long a) After this operation, the RangeSet contains the difference of itself and [a;a+1[.
- 
toArraypublic long[] toArray()Creates an array containing all the numbers in the RangeSet. Not recommended, because the arrays can become prohibitively large. It is preferrable to use a ValueIterator or explicit loops.
- 
fromArray
- 
toString
- 
valueIteratorReturns a ValueIterator, which iterates over all individual numbers in the RangeSet.
- 
toCompressedReturns a compressed representation of the RangeSet, using interpolative coding.- Throws:
- Exception
 
- 
fromCompressedReturns a RangeSet obtained by decompressing a byte array which was originally generated by toCompressed().- Throws:
- Exception
 
 
-