Package ghidra.util.datastruct
Class ObjectRangeMap<T>
java.lang.Object
ghidra.util.datastruct.ObjectRangeMap<T>
Associates objects with long index ranges.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clearRange
(long start, long end) Clears any object associations within the given range.boolean
contains
(long index) Returns true if the associated index has an associated object even if the assocated object is null.Returns anIndexRangeIterator
over all ranges that have associated objects.getIndexRangeIterator
(long start, long end) Returns anIndexRangeIterator
over all ranges that have associated objects within the given range.getObject
(long index) Returns the object associated with the given index or null if no object is associated with the given index.void
Associates the given object with all indices in the given range.
-
Constructor Details
-
ObjectRangeMap
public ObjectRangeMap()Constructs a new ObjectRangeMap
-
-
Method Details
-
getIndexRangeIterator
Returns anIndexRangeIterator
over all ranges that have associated objects.- Returns:
- an
IndexRangeIterator
over all ranges that have associated objects.
-
getIndexRangeIterator
Returns anIndexRangeIterator
over all ranges that have associated objects within the given range. Object Ranges that overlap the beginning or end of the given range are included, but have thier start or end index adjusted to be in the given range.- Parameters:
start
- the first index in the range to find all index ranges that have associated values.end
- the last index(inclusive) in the range to find all index ranges that have associated values.- Returns:
- an
IndexRangeIterator
over all ranges that have associated objects within the given range.
-
setObject
Associates the given object with all indices in the given range. The object may be null, but an assocition is still established. Use the clearRange() method to remove associations.- Parameters:
start
- the start of the range.end
- the end (inclusive) of the range.object
- the object to associate with the given range.
-
clearRange
public void clearRange(long start, long end) Clears any object associations within the given range.- Parameters:
start
- the first index in the range to be cleared.end
- the last index in the range to be cleared.
-
contains
public boolean contains(long index) Returns true if the associated index has an associated object even if the assocated object is null.- Parameters:
index
- the index to check for an association.- Returns:
- true if the associated index has an associated object even if the assocated object is null.
-
getObject
Returns the object associated with the given index or null if no object is associated with the given index. Note that null is a valid association so a null result could be either no association or an actual association of the index to null. Use the contains() method first if the distinction is important. If the contains() method returns true, the result is cached so the next call to getObject() will be fast.- Parameters:
index
- the index at which to retrieve an assocated object.- Returns:
- the object (which can be null) associated with the given index or null if no such association exists.
-