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

Public Member Functions

 __init__ (self)
 
Iterator[K__iter__ (self)
 
"ArraySet[K]" empty (cls)
 
int __len__ (self)
 
Union[K, list[K]] __getitem__ (self, Union[int, slice] index)
 
"ArraySet[K]" plusOrThis (self, K element)
 
- 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 59 of file ArrayMap.py.

Constructor & Destructor Documentation

◆ __init__()

selfie_lib.ArrayMap.ArraySet.__init__ (   self)

Definition at line 62 of file ArrayMap.py.

62 def __init__(self):
63 raise NotImplementedError("Use ArraySet.empty() or other class methods instead")
64

Member Function Documentation

◆ __getitem__()

Union[K, list[K]] selfie_lib.ArrayMap.ArraySet.__getitem__ (   self,
Union[int, slice]  index 
)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 83 of file ArrayMap.py.

83 def __getitem__(self, index: Union[int, slice]) -> Union[K, list[K]]:
84 return self.__data[index]
85

◆ __iter__()

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

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 71 of file ArrayMap.py.

71 def __iter__(self) -> Iterator[K]:
72 return iter(self.__data)
73

◆ __len__()

int selfie_lib.ArrayMap.ArraySet.__len__ (   self)

Reimplemented from selfie_lib.ArrayMap.ListBackedSet.

Definition at line 80 of file ArrayMap.py.

80 def __len__(self) -> int:
81 return len(self.__data)
82

◆ empty()

"ArraySet[K]" selfie_lib.ArrayMap.ArraySet.empty (   cls)

Definition at line 75 of file ArrayMap.py.

75 def empty(cls) -> "ArraySet[K]":
76 if not hasattr(cls, "__EMPTY"):
77 cls.__EMPTY = cls.__create([])
78 return cls.__EMPTY
79

◆ plusOrThis()

"ArraySet[K]" selfie_lib.ArrayMap.ArraySet.plusOrThis (   self,
K  element 
)

Definition at line 86 of file ArrayMap.py.

86 def plusOrThis(self, element: K) -> "ArraySet[K]":
87 index = self._binary_search(element)
88 if index >= 0:
89 return self
90 else:
91 insert_at = -(index + 1)
92 new_data = self.__data[:]
93 new_data.insert(insert_at, element)
94 return ArraySet.__create(new_data)
95
96

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