Set¶
- class Set(service_name, name, context)[source]¶
Bases:
PartitionSpecificProxy,Generic[ItemType]Concurrent, distributed implementation of Set
- add(item: ItemType) Future[bool][source]¶
Adds the specified item if it is not exists in this set.
- Parameters:
item – The specified item to be added.
- Returns:
Trueif this set is changed after call,Falseotherwise.
- add_all(items: Sequence[ItemType]) Future[bool][source]¶
Adds the elements in the specified collection if they’re not exist in this set.
- Parameters:
items – Collection which includes the items to be added.
- Returns:
Trueif this set is changed after call,Falseotherwise.
- add_listener(include_value: bool = False, item_added_func: Optional[Callable[[ItemEvent[ItemType]], None]] = None, item_removed_func: Optional[Callable[[ItemEvent[ItemType]], None]] = None) Future[str][source]¶
Adds an item listener for this container.
Listener will be notified for all container add/remove events.
- Parameters:
include_value – Whether received events include the updated item or not.
item_added_func – Function to be called when an item is added to this set.
item_removed_func – Function to be called when an item is deleted from this set.
- Returns:
A registration id which is used as a key to remove the listener.
- contains(item: ItemType) Future[bool][source]¶
Determines whether this set contains the specified item or not.
- Parameters:
item – The specified item to be searched.
- Returns:
Trueif the specified item exists in this set,Falseotherwise.
- contains_all(items: Sequence[ItemType]) Future[bool][source]¶
Determines whether this set contains all items in the specified collection or not.
- Parameters:
items – The specified collection which includes the items to be searched.
- Returns:
Trueif all the items in the specified collection exist in this set,Falseotherwise.
- get_all() Future[List[ItemType]][source]¶
Returns all the items in the set.
- Returns:
List of the items in this set.
- is_empty() Future[bool][source]¶
Determines whether this set is empty or not.
- Returns:
Trueif this set is empty,Falseotherwise.
- remove(item: ItemType) Future[bool][source]¶
Removes the specified element from the set if it exists.
- Parameters:
item – The specified element to be removed.
- Returns:
Trueif the specified element exists in this set,Falseotherwise.
- remove_all(items: Sequence[ItemType]) Future[bool][source]¶
Removes all of the elements of the specified collection from this set.
- Parameters:
items – The specified collection.
- Returns:
Trueif the call changed this set,Falseotherwise.
- remove_listener(registration_id: str) Future[bool][source]¶
Removes the specified item listener.
Returns silently if the specified listener was not added before.
- Parameters:
registration_id – Id of the listener to be deleted.
- Returns:
Trueif the item listener is removed,Falseotherwise.
- retain_all(items: Sequence[ItemType]) Future[bool][source]¶
Removes the items which are not contained in the specified collection.
In other words, only the items that are contained in the specified collection will be retained.
- Parameters:
items – Collection which includes the elements to be retained in this set.
- Returns:
Trueif this set changed as a result of the call,Falseotherwise.
- size() Future[int][source]¶
Returns the number of items in this set.
- Returns:
Number of items in this set.
- blocking() BlockingSet[ItemType][source]¶
Returns a version of this proxy with only blocking method calls.
- class BlockingSet(wrapped: Set[ItemType])[source]¶
Bases:
Set[ItemType]- name¶
- service_name¶
- add(item: ItemType) bool[source]¶
Adds the specified item if it is not exists in this set.
- Parameters:
item – The specified item to be added.
- Returns:
Trueif this set is changed after call,Falseotherwise.
- add_all(items: Sequence[ItemType]) bool[source]¶
Adds the elements in the specified collection if they’re not exist in this set.
- Parameters:
items – Collection which includes the items to be added.
- Returns:
Trueif this set is changed after call,Falseotherwise.
- add_listener(include_value: bool = False, item_added_func: Optional[Callable[[ItemEvent[ItemType]], None]] = None, item_removed_func: Optional[Callable[[ItemEvent[ItemType]], None]] = None) str[source]¶
Adds an item listener for this container.
Listener will be notified for all container add/remove events.
- Parameters:
include_value – Whether received events include the updated item or not.
item_added_func – Function to be called when an item is added to this set.
item_removed_func – Function to be called when an item is deleted from this set.
- Returns:
A registration id which is used as a key to remove the listener.
- contains(item: ItemType) bool[source]¶
Determines whether this set contains the specified item or not.
- Parameters:
item – The specified item to be searched.
- Returns:
Trueif the specified item exists in this set,Falseotherwise.
- contains_all(items: Sequence[ItemType]) bool[source]¶
Determines whether this set contains all items in the specified collection or not.
- Parameters:
items – The specified collection which includes the items to be searched.
- Returns:
Trueif all the items in the specified collection exist in this set,Falseotherwise.
- get_all() List[ItemType][source]¶
Returns all the items in the set.
- Returns:
List of the items in this set.
- is_empty() bool[source]¶
Determines whether this set is empty or not.
- Returns:
Trueif this set is empty,Falseotherwise.
- remove(item: ItemType) bool[source]¶
Removes the specified element from the set if it exists.
- Parameters:
item – The specified element to be removed.
- Returns:
Trueif the specified element exists in this set,Falseotherwise.
- remove_all(items: Sequence[ItemType]) bool[source]¶
Removes all of the elements of the specified collection from this set.
- Parameters:
items – The specified collection.
- Returns:
Trueif the call changed this set,Falseotherwise.
- remove_listener(registration_id: str) bool[source]¶
Removes the specified item listener.
Returns silently if the specified listener was not added before.
- Parameters:
registration_id – Id of the listener to be deleted.
- Returns:
Trueif the item listener is removed,Falseotherwise.
- retain_all(items: Sequence[ItemType]) bool[source]¶
Removes the items which are not contained in the specified collection.
In other words, only the items that are contained in the specified collection will be retained.
- Parameters:
items – Collection which includes the elements to be retained in this set.
- Returns:
Trueif this set changed as a result of the call,Falseotherwise.
- blocking() BlockingSet[ItemType][source]¶
Returns a version of this proxy with only blocking method calls.