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

True if this set is changed after call, False otherwise.

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

True if this set is changed after call, False otherwise.

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.

clear() Future[None][source]

Clears the set. Set will be empty with this call.

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

True if the specified item exists in this set, False otherwise.

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

True if all the items in the specified collection exist in this set, False otherwise.

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

True if this set is empty, False otherwise.

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

True if the specified element exists in this set, False otherwise.

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

True if the call changed this set, False otherwise.

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

True if the item listener is removed, False otherwise.

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

True if this set changed as a result of the call, False otherwise.

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

True if this set is changed after call, False otherwise.

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

True if this set is changed after call, False otherwise.

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.

clear() None[source]

Clears the set. Set will be empty with this call.

contains(item: ItemType) bool[source]

Determines whether this set contains the specified item or not.

Parameters

item – The specified item to be searched.

Returns

True if the specified item exists in this set, False otherwise.

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

True if all the items in the specified collection exist in this set, False otherwise.

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

True if this set is empty, False otherwise.

remove(item: ItemType) bool[source]

Removes the specified element from the set if it exists.

Parameters

item – The specified element to be removed.

Returns

True if the specified element exists in this set, False otherwise.

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

True if the call changed this set, False otherwise.

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

True if the item listener is removed, False otherwise.

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

True if this set changed as a result of the call, False otherwise.

size() 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.

destroy() bool[source]

Destroys this proxy.

Returns

True if this proxy is destroyed successfully, False otherwise.