Package com.pnfsoftware.jeb.util.collect
Class IntGauge
java.lang.Object
com.pnfsoftware.jeb.util.collect.IntGauge
An integer gauge is used to define an integer range to be filled. The range must be reasonably
small (for larger ranges (million+), a custom implementation relying
ISegmentMap may be
better suited in terms of memory usage).
Example:
- a range [20, 100] is specified
- calls to record may be used to record partial filling of the
gauge:
record(10, 30), record(56, 60), record(0, 10)
- the order of the fillings does not matter; however, overlaps are not allowed:
e.g. if the sub-range [10,30[ was recorded and is present, adding a range [25,40[ would be
rejected (record() would return false)
- when the gauge is complete, isComplete() returns true
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
IntGauge
public IntGauge(int size) Create a gauge whose range goes from 0 tosize. The range must be reasonably small (recommendation: less than 1M).- Parameters:
size- range end, exclusive
-
IntGauge
public IntGauge(int begin, int end) Create a gauge whose range goes frombegintoend(exclusive). The range must be reasonably small (recommendation: less than 1M).- Parameters:
begin- range begin, inclusiveend- range end, exclusive
-
-
Method Details
-
clear
public void clear()Clear all recorded sub-ranges. -
getBegin
public int getBegin()- Returns:
- range begin, inclusive
-
getEnd
public int getEnd()- Returns:
- range end, exclusive
-
record
public boolean record(int begin, int end) Record a filled sub-range.- Parameters:
begin- sub-range begin, inclusiveend- sub-range end, exclusive- Returns:
- true if the sub-range was recorded; false if it was invalid or overlapped existing records
-
getRemaining
public int getRemaining()- Returns:
- number of positions not yet recorded
-
isComplete
public boolean isComplete()- Returns:
- true if the whole range has been recorded
-
hashCode
public int hashCode() -
equals
-
toString
-