Selfie
Loading...
Searching...
No Matches
selfie_lib.ArrayMap._ArrayMapEntries Class Reference
Inheritance diagram for selfie_lib.ArrayMap._ArrayMapEntries:
selfie_lib.ArrayMap.ListBackedSet

Public Member Functions

 __init__ (self, list[Union[K, V]] data)
 
int __len__ (self)
 
 __getitem__ (self, Union[int, slice] index)
 
Iterator[tuple[K, V]] __iter__ (self)
 
- Public Member Functions inherited from selfie_lib.ArrayMap.ListBackedSet
bool __contains__ (self, Any item)
 

Additional Inherited Members

- Protected Member Functions inherited from selfie_lib.ArrayMap.ListBackedSet
int _binary_search (self, Any item)
 

Detailed Description

Definition at line 121 of file ArrayMap.py.

Constructor & Destructor Documentation

◆ __init__()

selfie_lib.ArrayMap._ArrayMapEntries.__init__ (   self,
list[Union[K, V]]  data 
)

Definition at line 122 of file ArrayMap.py.

122 def __init__(self, data: list[Union[K, V]]):
123 self.__data = data
124

Member Function Documentation

◆ __getitem__()

selfie_lib.ArrayMap._ArrayMapEntries.__getitem__ (   self,
Union[int, slice]  index 
)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 128 of file ArrayMap.py.

128 def __getitem__(self, index: Union[int, slice]): # type: ignore
129 if isinstance(index, slice):
130 return [
131 (self.__data[i], self.__data[i + 1])
132 for i in range(
133 index.start * 2 if index.start else 0,
134 index.stop * 2 if index.stop else len(self.__data),
135 index.step * 2 if index.step else 2,
136 )
137 ]
138 else:
139 return (self.__data[2 * index], self.__data[2 * index + 1])
140

◆ __iter__()

Iterator[tuple[K, V]] selfie_lib.ArrayMap._ArrayMapEntries.__iter__ (   self)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 141 of file ArrayMap.py.

141 def __iter__(self) -> Iterator[tuple[K, V]]:
142 return (
143 (self.__data[i], self.__data[i + 1]) for i in range(0, len(self.__data), 2)
144 ) # type: ignore
145
146

◆ __len__()

int selfie_lib.ArrayMap._ArrayMapEntries.__len__ (   self)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 125 of file ArrayMap.py.

125 def __len__(self) -> int:
126 return len(self.__data) // 2
127

The documentation for this class was generated from the following file: