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

Public Member Functions

 __init__ (self, list[Union[K, V]] data)
 
int __len__ (self)
 
 __getitem__ (self, Union[int, slice] index)
 
Iterator[K__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 97 of file ArrayMap.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 98 of file ArrayMap.py.

98 def __init__(self, data: list[Union[K, V]]):
99 self.__data = data
100

Member Function Documentation

◆ __getitem__()

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

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 104 of file ArrayMap.py.

104 def __getitem__(self, index: Union[int, slice]): # type: ignore
105 if isinstance(index, slice):
106 return [
107 self.__data[i]
108 for i in range(
109 index.start * 2 if index.start else 0,
110 index.stop * 2 if index.stop else len(self.__data),
111 index.step * 2 if index.step else 2,
112 )
113 ]
114 else:
115 return self.__data[2 * index]
116

◆ __iter__()

Iterator[K] selfie_lib.ArrayMap._ArrayMapKeys.__iter__ (   self)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 117 of file ArrayMap.py.

117 def __iter__(self) -> Iterator[K]:
118 return (self.__data[i] for i in range(0, len(self.__data), 2)) # type: ignore
119
120

◆ __len__()

int selfie_lib.ArrayMap._ArrayMapKeys.__len__ (   self)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 101 of file ArrayMap.py.

101 def __len__(self) -> int:
102 return len(self.__data) // 2
103

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