ordered_set package¶
Module contents¶
-
class
ordered_hash_set.
OrderedSet
(*items)[source]¶ Bases:
object
-
add
(item)[source]¶ Adds the item to set if it is not exist. Returns the index of added item (or already existing item) in the respective set. Raises TypeError if specified item is not hashable
Parameters: item – (object), item to be added.
-
contains
(item)¶
-
contains_all
(*items)[source]¶ Determines whether this set contains all of the items in the specified collection or not.
Parameters: items – (tuple), the specified items to be searched. Returns: (bool), True
if all of the items in the specified collection exist in this set,False
otherwise.
-
contains_any
(*items)[source]¶ Checks whether any of the items exists in this set or not.
Parameters: items – (tuple), items to be searched. Returns: (bool), True
if any of the items in the specified collection exist in this set,False
otherwise.
-
difference
(*other)[source]¶ Returns a new set with elements in the set that are not in the others.
Parameters: *other – (list | set | OrderedSet), The sets to check difference.
Returns: (OrderedSet) The set of the different elements.
-
drain
(reverse=False)[source]¶ Returns a iterator that removes items from set and yields them.
Parameters: reverse – If reverse is True
items are yielded from end to start.Returns: (Iterator), iterator that consumes items.
-
get_all
()[source]¶ Returns a list containing all items.
Returns: (list), Specified list that contains all items in the set.
-
intersection
(*other)[source]¶ Returns a new ordered set with elements common to the set and all others.
Parameters: *other – (list | set | OrderedSet), The sets to check common.
Returns: (OrderedSet) the set with elements common to the OrderedSet object and all *other
.
-
is_disjoint
(other)[source]¶ Returns
True
if the set has no elements in common withother
. Sets(also OrderedSets) are disjoint if and only if their intersection is the empty set.Parameters: other – (list | set | OrderedSet), Checked object. Returns: (bool) If the set has no elements in common with other return True.
-
is_empty
()[source]¶ Determines whether this set is empty or not.
Returns: (bool), True
if this set is empty,False
otherwise.
-
is_subset
(other)[source]¶ Tests whether every element in the set is in other.
Parameters: other – (list | set | OrderedSet), Checked object. Returns: (bool) If the set is a subset of other
returnTrue
.
-
is_superset
(other)[source]¶ Tests whether every element in other is in the set.
Parameters: other – (list | set | OrderedSet), Checked object. Returns: (bool) If the set is the superset of other
returnTrue
.
-
remove
(item)[source]¶ Removes given item from set. Returns the used index of the removed item in the respective set. Raises ValueError if item is not found.
Parameters: item – (object), Removed item
-
remove_all
(*items)[source]¶ Removes all given items. Raises KeyError if any of the items is not found in the set.
Parameters: items – (tuple), Items to be removed.
-