Package ghidra.util.datastruct
Class RangeMap
java.lang.Object
ghidra.util.datastruct.RangeMap
Stores ranges of int values throughout "long" space. Every "long" index has
an associated int value (initially 0). Users can paint (set) ranges of
indexes to a given integer value, overwriting any value that currently exists
in that range.
This class is implemented using an IntPropertyMap. The first index
(0) will always contain a value. The value at any other given
index will either be the value stored at that index, or if no
value stored there, then the value stored at the nearest previous index
that contains a value.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all current values from the range map and resets the default value.getChangePointIterator
(long start, long end) Returns an iterator over all indexes where the value changes.getIndexRangeIterator
(long index) Returns an iterator over all occupied ranges in the map.int
Get the total number of ranges in map.int
getValue
(long index) Returns the int value associated with the given index.getValueRange
(long index) Returns the value range containing the given index.void
paintRange
(long start, long end, int value) Associates the given value with every index from start to end (inclusive) Any previous associates are overwritten.
-
Constructor Details
-
RangeMap
public RangeMap()Constructor for RangeMap with a default value of 0. -
RangeMap
public RangeMap(int defaultValue) Creates a new range map with spcified default value.- Parameters:
defaultValue
- the default value
-
-
Method Details
-
getNumRanges
public int getNumRanges()Get the total number of ranges in map.- Returns:
- number of ranges
-
clear
public void clear()Clears all current values from the range map and resets the default value. -
paintRange
public void paintRange(long start, long end, int value) Associates the given value with every index from start to end (inclusive) Any previous associates are overwritten.- Parameters:
start
- the start index of the range to fill.end
- the end index of the range to fillvalue
- the value to put at every index in the range.
-
getValue
public int getValue(long index) Returns the int value associated with the given index.- Parameters:
index
- the index at which to get the value.
-
getValueRange
Returns the value range containing the given index. The value range indicates the int value and the start and end index for the range.- Parameters:
index
- the index at which to get the associated value range- Returns:
- the value range
-
getIndexRangeIterator
Returns an iterator over all occupied ranges in the map.- Parameters:
index
- the index to start the iterator- Returns:
- an iterator over all occupied ranges in the map.
-
getChangePointIterator
Returns an iterator over all indexes where the value changes.- Parameters:
start
- the starting index to search.end
- the ending index to search.- Returns:
- an iterator over all indexes where the value changes.
-