navigate.model.features.feature_related_functions.SharedList
- class navigate.model.features.feature_related_functions.SharedList(value: Iterable, name: Optional[str] = None)
Bases:
list
Custom list class with a name attribute for sharing data.
This class extends the built-in list class to provide an additional attribute called ‘name’ for identifying and sharing lists of data. It is particularly useful when sharing data between different parts of a program.
Notes:
This class is designed to be used when you need to pass and share lists of data between different components of a program.
The ‘__name__’ attribute can be used to give the shared list a meaningful name for easier identification.
- __init__(value: Iterable, name: Optional[str] = None) → None
Initialize a SharedList object.
Parameters:
- valueIterable
Initial values for the list (default is an empty list).
- nameOptional[str]
A name to identify the shared list (default is ‘shared_list__’).
Methods
__init__
(value[, name])Initialize a SharedList object.
append
(object, /)Append object to the end of the list.
clear
()Remove all items from list.
copy
()Return a shallow copy of the list.
count
(value, /)Return number of occurrences of value.
extend
(iterable, /)Extend list by appending elements from the iterable.
index
(value[, start, stop])Return first index of value.
insert
(index, object, /)Insert object before index.
pop
([index])Remove and return item at index (default last).
remove
(value, /)Remove first occurrence of value.
reverse
()Reverse IN PLACE.
sort
(*[, key, reverse])Sort the list in ascending order and return None.
- append(object, /)
Append object to the end of the list.
- clear()
Remove all items from list.
- copy()
Return a shallow copy of the list.
- count(value, /)
Return number of occurrences of value.
- extend(iterable, /)
Extend list by appending elements from the iterable.
- index(value, start=0, stop=9223372036854775807, /)
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)
Insert object before index.
- pop(index=-1, /)
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()
Reverse IN PLACE.
- sort(*, key=None, reverse=False)
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.