class documentation

class MemoryRangeMap(_Generic[_address.AddressType, _DataType]):

View In Hierarchy

A map of non-overlapping memory ranges to some data.

The data of memory ranges that would overlap is merged/subtracted with the one of a memory range that would be added/removed from the map.

Method __init__ Creates a new instance of MemoryRangeMap.
Method __iter__ Undocumented
Method __len__ Returns the number of memory ranges in this map.
Method add Adds the passed memory range with the associated data to the map.
Method intersection Iterates over the intersection of any memory range contained in the map with the passed memory range, returning their associated data.
Method keys Returns an iterator on all the memory ranges in the map.
Method remove Removes the passed memory range with the associated data from the map.
Method remove_iter Removes the passed memory range with the associated data from the map, iterating on the removed elements.
Method _compare_insert_left Returns: new index value where next element should be inserted, and whether we should stop immediately
Method _compare_insert_right Returns: new index value where next element should be inserted, and whether we should stop immediately
Method _first_index_to_look_at Undocumented
Method _fuse_contiguous Undocumented
Method _insert Undocumented
Instance Variable _merge Undocumented
Instance Variable _ranges Undocumented
Instance Variable _subtract Undocumented
def __init__(self, merge, subtract, items=()):

Creates a new instance of MemoryRangeMap.

Information

Parameters
merge:_Callable[[_DataType, _DataType], _DataType]Function indicating how to merge data when adding overlapping ranges.
subtract:_Callable[[_DataType, _DataType], _Optional[_DataType]]Function indicating how to subtract data when removing overlapping ranges. A return value of None will remove the corresponding memory range.
items:_Iterable[_Tuple[MemoryRange[_address.AddressType], _DataType]]Initial (keys, values) for the map. If they overlap, they will be merged upon insertion.
def __iter__(self):

Undocumented

Returns
_Iterator[_Tuple[MemoryRange[_address.AddressType], _DataType]]Undocumented
def __len__(self):

Returns the number of memory ranges in this map.

Returns
intUndocumented
def add(self, memory_range, data):

Adds the passed memory range with the associated data to the map.

The memory range can overlap with keys already contained in the map. After the addition, the intersecting range will contain the data obtained by merging the passed data with the data of the overlapping existing range.

After the addition, contiguous ranges associated to the same data (in the sense of the data type's __eq__ method) will be replaced by their union.

Parameters
memory_range:_Union[_address.AddressType, MemoryRange[_address.AddressType]]Undocumented
data:_DataTypeUndocumented
def intersection(self, memory_range):

Iterates over the intersection of any memory range contained in the map with the passed memory range, returning their associated data.

Parameters
memory_range:_Union[_address.AddressType, MemoryRange[_address.AddressType]]Undocumented
Returns
_Iterator[_Tuple[MemoryRange[_address.AddressType], _DataType]]Undocumented
def keys(self):

Returns an iterator on all the memory ranges in the map.

Returns
_Iterator[MemoryRange[_address.AddressType]]Undocumented
def remove(self, memory_range, data=None):

Removes the passed memory range with the associated data from the map.

The passed data will be subtracted from the data associated with any overlapping existing range, and the resulting data will be associated with the intersection of such ranges. If the subtracted data is None for a range after this operation, then the range will be removed from the map.

If the passed data is None, then the intersection of any range overlapping with the passed range will always be removed regardless of its data.

After the removal, contiguous ranges associated to the same data (in the sense of the data type's __eq__ method) will be replaced by their union.

Parameters
memory_range:_Union[_address.AddressType, MemoryRange[_address.AddressType]]Undocumented
data:_Optional[_DataType]Undocumented
def remove_iter(self, memory_range, data=None):

Removes the passed memory range with the associated data from the map, iterating on the removed elements.

For each removed range, returns a tuple containing that range and the data that was removed from the map.

After this iterator is fully consumed or deleted, contiguous ranges associated to the same data (in the sense of the data type's __eq__ method) will be replaced by their union.

Parameters
memory_range:_Union[_address.AddressType, MemoryRange[_address.AddressType]]Undocumented
data:_Optional[_DataType]Undocumented
Returns
_Iterator[_Tuple[MemoryRange[_address.AddressType], _Optional[_DataType]]]Undocumented
def _compare_insert_left(self, new, existing, intersection, index):

Returns: new index value where next element should be inserted, and whether we should stop immediately

Parameters
new:_LexicographicKeyVal[_address.AddressType, _DataType]Undocumented
existing:_LexicographicKeyVal[_address.AddressType, _DataType]Undocumented
intersection:MemoryRange[_address.AddressType]Undocumented
index:intUndocumented
Returns
_Tuple[int, bool]Undocumented
def _compare_insert_right(self, new, existing, intersection, index):

Returns: new index value where next element should be inserted, and whether we should stop immediately

Parameters
new:_LexicographicKeyVal[_address.AddressType, _DataType]Undocumented
existing:_LexicographicKeyVal[_address.AddressType, _DataType]Undocumented
intersection:MemoryRange[_address.AddressType]Undocumented
index:intUndocumented
Returns
_Tuple[int, bool]Undocumented
def _first_index_to_look_at(self, memory_range):

Undocumented

Parameters
memory_range:_Union[_address.AddressType, MemoryRange[_address.AddressType]]Undocumented
Returns
_Tuple[MemoryRange[_address.AddressType], int]Undocumented
def _fuse_contiguous(self, begin_index, end_index):

Undocumented

Parameters
begin_index:intUndocumented
end_index:intUndocumented
def _insert(self, index, range, data):

Undocumented

Parameters
index:intUndocumented
range:MemoryRange[_address.AddressType]Undocumented
data:_DataTypeUndocumented
Returns
intUndocumented
_merge =

Undocumented

Undocumented

_subtract =

Undocumented