class documentation

class RegisterSliceMap(_Generic[_DataType]):

View In Hierarchy

A map of non-overlapping register slices associated to some data.

The data of register slices that would overlap is merged/subtracted with the one of a register slice that would be added/removed from the map.

Method __init__ Creates a new instance of RegisterSliceMap.
Method __iter__ Undocumented
Method __len__ Returns the number of register slices in this map.
Method add Adds the passed register slice with the associated data to the map.
Method intersection Iterates over the intersection of any register slice contained in the map with the passed slice, returning their associated data.
Method keys Returns an iterator on all the register slices in the map.
Method remove Removes the passed register slice with the associated data from the map.
Method remove_iter Removes the passed register slice with the associated data from the map, iterating on the removed elements.
Property register_count The number of different register that are sliced in this map.
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 _slices Undocumented
Instance Variable _subtract Undocumented
def __init__(self, merge, subtract, items=()):

Creates a new instance of RegisterSliceMap.

Information

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

Undocumented

Returns
_Iterator[_Tuple[RegisterSlice, _DataType]]Undocumented
def __len__(self):

Returns the number of register slices in this map.

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

Adds the passed register slice with the associated data to the map.

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

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

Parameters
register_slice:_Union[_Register, RegisterSlice]Undocumented
data:_DataTypeUndocumented
def intersection(self, register_slice):

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

Parameters
register_slice:_Union[_Register, RegisterSlice]Undocumented
Returns
_Iterator[_Tuple[RegisterSlice, _DataType]]Undocumented
def keys(self):

Returns an iterator on all the register slices in the map.

Returns
_Iterator[RegisterSlice]Undocumented
def remove(self, register_slice, data=None):

Removes the passed register slice with the associated data from the map.

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

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

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

Parameters
register_slice:_Union[_Register, RegisterSlice]Undocumented
data:_Optional[_DataType]Undocumented
def remove_iter(self, register_slice, data=None):

Removes the passed register slice with the associated data from the map, iterating on the removed elements.

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

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

Parameters
register_slice:_Union[_Register, RegisterSlice]Undocumented
data:_Optional[_DataType]Undocumented
Returns
_Iterator[_Tuple[RegisterSlice, _Optional[_DataType]]]Undocumented
@property
register_count: int =

The number of different register that are sliced in this map.

def _compare_insert_left(self, new, existing, slices, intersection, index):

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

Parameters
new:_LexicographicKeyVal[_DataType]Undocumented
existing:_LexicographicKeyVal[_DataType]Undocumented
slices:_List[_LexicographicKeyVal[_DataType]]Undocumented
intersection:RegisterSliceUndocumented
index:intUndocumented
Returns
_Tuple[int, bool]Undocumented
def _compare_insert_right(self, new, existing, slices, intersection, index):

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

Parameters
new:_LexicographicKeyVal[_DataType]Undocumented
existing:_LexicographicKeyVal[_DataType]Undocumented
slices:_List[_LexicographicKeyVal[_DataType]]Undocumented
intersection:RegisterSliceUndocumented
index:intUndocumented
Returns
_Tuple[int, bool]Undocumented
def _first_index_to_look_at(self, register_slice):

Undocumented

Parameters
register_slice:_Union[_Register, RegisterSlice]Undocumented
Returns
_Optional[_Tuple[RegisterSlice, _List[_LexicographicKeyVal[_DataType]], int]]Undocumented
def _fuse_contiguous(self, slices, begin_index, end_index):

Undocumented

Parameters
slices:_List[_LexicographicKeyVal[_DataType]]Undocumented
begin_index:intUndocumented
end_index:intUndocumented
def _insert(self, slices, index, slice, data):

Undocumented

Parameters
slices:_List[_LexicographicKeyVal[_DataType]]Undocumented
index:intUndocumented
slice:RegisterSliceUndocumented
data:_DataTypeUndocumented
Returns
intUndocumented
_merge =

Undocumented

_slices: dict[_Register, _List[_LexicographicKeyVal[_DataType]]] =

Undocumented

_subtract =

Undocumented