List

class List(service_name, name, context)[source]

Bases: hazelcast.proxy.base.PartitionSpecificProxy[BlockingList], Generic[hazelcast.types.ItemType]

Concurrent, distributed implementation of List.

The Hazelcast List is not a partitioned data-structure. So all the content of the List is stored in a single machine (and in the backup). So the List will not scale by adding more members in the cluster.

add(item: hazelcast.types.ItemType) hazelcast.future.Future[bool][source]

Adds the specified item to the end of this list.

Parameters

item – the specified item to be appended to this list.

Returns

True if item is added, False otherwise.

add_at(index: int, item: hazelcast.types.ItemType) hazelcast.future.Future[None][source]

Adds the specified item at the specific position in this list. Element in this position and following elements are shifted to the right, if any.

Parameters
  • index – The specified index to insert the item.

  • item – The specified item to be inserted.

add_all(items: Sequence[hazelcast.types.ItemType]) hazelcast.future.Future[bool][source]

Adds all of the items in the specified collection to the end of this list.

The order of new elements is determined by the specified collection’s iterator.

Parameters

items – The specified collection which includes the elements to be added to list.

Returns

True if this call changed the list, False otherwise.

add_all_at(index: int, items: Sequence[hazelcast.types.ItemType]) hazelcast.future.Future[bool][source]

Adds all of the elements in the specified collection into this list at the specified position.

Elements in this positions and following elements are shifted to the right, if any. The order of new elements is determined by the specified collection’s iterator.

Parameters
  • index – The specified index at which the first element of specified collection is added.

  • items – The specified collection which includes the elements to be added to list.

Returns

True if this call changed the list, False otherwise.

add_listener(include_value: bool = False, item_added_func: Optional[Callable[[hazelcast.proxy.base.ItemEvent[hazelcast.types.ItemType]], None]] = None, item_removed_func: Optional[Callable[[hazelcast.proxy.base.ItemEvent[hazelcast.types.ItemType]], None]] = None) hazelcast.future.Future[str][source]

Adds an item listener for this list. Listener will be notified for all list add/remove events.

Parameters
  • include_value – Whether received events include the updated item or not.

  • item_added_func – To be called when an item is added to this list.

  • item_removed_func – To be called when an item is deleted from this list.

Returns

A registration id which is used as a key to remove the listener.

clear() hazelcast.future.Future[None][source]

Clears the list.

List will be empty with this call.

contains(item: hazelcast.types.ItemType) hazelcast.future.Future[bool][source]

Determines whether this list contains the specified item or not.

Parameters

item – The specified item.

Returns

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

contains_all(items: Sequence[hazelcast.types.ItemType]) hazelcast.future.Future[bool][source]

Determines whether this list contains all of the items in specified collection or not.

Parameters

items – The specified collection which includes the items to be searched.

Returns

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

get(index: int) hazelcast.future.Future[hazelcast.types.ItemType][source]

Returns the item which is in the specified position in this list.

Parameters

index – the specified index of the item to be returned.

Returns

The item in the specified position in this list.

get_all() hazelcast.future.Future[List[hazelcast.types.ItemType]][source]

Returns all the items in this list.

Returns

All the items in this list.

iterator() hazelcast.future.Future[List[hazelcast.types.ItemType]][source]

Returns an iterator over the elements in this list in proper sequence, same with get_all.

Returns

All the items in this list.

index_of(item: hazelcast.types.ItemType) hazelcast.future.Future[int][source]

Returns the first index of specified item’s occurrences in this list.

If specified item is not present in this list, returns -1.

Parameters

item – The specified item to be searched for.

Returns

The first index of specified item’s occurrences, -1 if item is not present in this list.

is_empty() hazelcast.future.Future[bool][source]

Determines whether this list is empty or not.

Returns

True if the list contains no elements, False otherwise.

last_index_of(item: hazelcast.types.ItemType) hazelcast.future.Future[int][source]

Returns the last index of specified item’s occurrences in this list.

If specified item is not present in this list, returns -1.

Parameters

item – The specified item to be searched for.

Returns

The last index of specified item’s occurrences, -1 if item is not present in this list.

list_iterator(index: int = 0) hazelcast.future.Future[List[hazelcast.types.ItemType]][source]

Returns a list iterator of the elements in this list.

If an index is provided, iterator starts from this index.

Parameters

index – Index of first element to be returned from the list iterator.

Returns

List of the elements in this list.

remove(item: hazelcast.types.ItemType) hazelcast.future.Future[bool][source]

Removes the specified element’s first occurrence from the list if it exists in this list.

Parameters

item – The specified element.

Returns

True if the specified element is present in this list, False otherwise.

remove_at(index: int) hazelcast.future.Future[hazelcast.types.ItemType][source]

Removes the item at the specified position in this list.

Element in this position and following elements are shifted to the left, if any.

Parameters

index – Index of the item to be removed.

Returns

The item previously at the specified index.

remove_all(items: Sequence[hazelcast.types.ItemType]) hazelcast.future.Future[bool][source]

Removes all of the elements that is present in the specified collection from this list.

Parameters

items – The specified collection.

Returns

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

remove_listener(registration_id: str) hazelcast.future.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[hazelcast.types.ItemType]) hazelcast.future.Future[bool][source]

Retains only the items that are contained in the specified collection.

It means, items which are not present in the specified collection are removed from this list.

Parameters

items – Collections which includes the elements to be retained in this list.

Returns

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

size() hazelcast.future.Future[int][source]

Returns the number of elements in this list.

Returns

Number of elements in this list.

set_at(index: int, item: hazelcast.types.ItemType) hazelcast.future.Future[hazelcast.types.ItemType][source]

Replaces the specified element with the element at the specified position in this list.

Parameters
  • index – Index of the item to be replaced.

  • item – Item to be stored.

Returns

The previous item in the specified index.

sub_list(from_index: int, to_index: int) hazelcast.future.Future[List[hazelcast.types.ItemType]][source]

Returns a sublist from this list, from from_index(inclusive) to to_index(exclusive).

The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.

Parameters
  • from_index – The start point(inclusive) of the sub_list.

  • to_index – The end point(exclusive) of the sub_list.

Returns

A view of the specified range within this list.

blocking() hazelcast.proxy.list.BlockingList[hazelcast.types.ItemType][source]

Returns a version of this proxy with only blocking method calls.

class BlockingList(wrapped: hazelcast.proxy.list.List[hazelcast.types.ItemType])[source]

Bases: hazelcast.proxy.list.List[hazelcast.types.ItemType]

name
service_name
add(item: hazelcast.types.ItemType) bool[source]

Adds the specified item to the end of this list.

Parameters

item – the specified item to be appended to this list.

Returns

True if item is added, False otherwise.

add_at(index: int, item: hazelcast.types.ItemType) None[source]

Adds the specified item at the specific position in this list. Element in this position and following elements are shifted to the right, if any.

Parameters
  • index – The specified index to insert the item.

  • item – The specified item to be inserted.

add_all(items: Sequence[hazelcast.types.ItemType]) bool[source]

Adds all of the items in the specified collection to the end of this list.

The order of new elements is determined by the specified collection’s iterator.

Parameters

items – The specified collection which includes the elements to be added to list.

Returns

True if this call changed the list, False otherwise.

add_all_at(index: int, items: Sequence[hazelcast.types.ItemType]) bool[source]

Adds all of the elements in the specified collection into this list at the specified position.

Elements in this positions and following elements are shifted to the right, if any. The order of new elements is determined by the specified collection’s iterator.

Parameters
  • index – The specified index at which the first element of specified collection is added.

  • items – The specified collection which includes the elements to be added to list.

Returns

True if this call changed the list, False otherwise.

add_listener(include_value: bool = False, item_added_func: Optional[Callable[[hazelcast.proxy.base.ItemEvent[hazelcast.types.ItemType]], None]] = None, item_removed_func: Optional[Callable[[hazelcast.proxy.base.ItemEvent[hazelcast.types.ItemType]], None]] = None) str[source]

Adds an item listener for this list. Listener will be notified for all list add/remove events.

Parameters
  • include_value – Whether received events include the updated item or not.

  • item_added_func – To be called when an item is added to this list.

  • item_removed_func – To be called when an item is deleted from this list.

Returns

A registration id which is used as a key to remove the listener.

clear() None[source]

Clears the list.

List will be empty with this call.

contains(item: hazelcast.types.ItemType) bool[source]

Determines whether this list contains the specified item or not.

Parameters

item – The specified item.

Returns

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

contains_all(items: Sequence[hazelcast.types.ItemType]) bool[source]

Determines whether this list contains all of the items in specified collection or not.

Parameters

items – The specified collection which includes the items to be searched.

Returns

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

get(index: int) hazelcast.types.ItemType[source]

Returns the item which is in the specified position in this list.

Parameters

index – the specified index of the item to be returned.

Returns

The item in the specified position in this list.

get_all() List[hazelcast.types.ItemType][source]

Returns all the items in this list.

Returns

All the items in this list.

iterator() List[hazelcast.types.ItemType][source]

Returns an iterator over the elements in this list in proper sequence, same with get_all.

Returns

All the items in this list.

index_of(item: hazelcast.types.ItemType) int[source]

Returns the first index of specified item’s occurrences in this list.

If specified item is not present in this list, returns -1.

Parameters

item – The specified item to be searched for.

Returns

The first index of specified item’s occurrences, -1 if item is not present in this list.

is_empty() hazelcast.future.Future[bool][source]

Determines whether this list is empty or not.

Returns

True if the list contains no elements, False otherwise.

last_index_of(item: hazelcast.types.ItemType) int[source]

Returns the last index of specified item’s occurrences in this list.

If specified item is not present in this list, returns -1.

Parameters

item – The specified item to be searched for.

Returns

The last index of specified item’s occurrences, -1 if item is not present in this list.

list_iterator(index: int = 0) List[hazelcast.types.ItemType][source]

Returns a list iterator of the elements in this list.

If an index is provided, iterator starts from this index.

Parameters

index – Index of first element to be returned from the list iterator.

Returns

List of the elements in this list.

remove(item: hazelcast.types.ItemType) bool[source]

Removes the specified element’s first occurrence from the list if it exists in this list.

Parameters

item – The specified element.

Returns

True if the specified element is present in this list, False otherwise.

remove_at(index: int) hazelcast.types.ItemType[source]

Removes the item at the specified position in this list.

Element in this position and following elements are shifted to the left, if any.

Parameters

index – Index of the item to be removed.

Returns

The item previously at the specified index.

remove_all(items: Sequence[hazelcast.types.ItemType]) bool[source]

Removes all of the elements that is present in the specified collection from this list.

Parameters

items – The specified collection.

Returns

True if this list changed as a result of the call, 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[hazelcast.types.ItemType]) bool[source]

Retains only the items that are contained in the specified collection.

It means, items which are not present in the specified collection are removed from this list.

Parameters

items – Collections which includes the elements to be retained in this list.

Returns

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

size() int[source]

Returns the number of elements in this list.

Returns

Number of elements in this list.

set_at(index: int, item: hazelcast.types.ItemType) hazelcast.types.ItemType[source]

Replaces the specified element with the element at the specified position in this list.

Parameters
  • index – Index of the item to be replaced.

  • item – Item to be stored.

Returns

The previous item in the specified index.

sub_list(from_index: int, to_index: int) List[hazelcast.types.ItemType][source]

Returns a sublist from this list, from from_index(inclusive) to to_index(exclusive).

The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.

Parameters
  • from_index – The start point(inclusive) of the sub_list.

  • to_index – The end point(exclusive) of the sub_list.

Returns

A view of the specified range within this list.

blocking() hazelcast.proxy.list.BlockingList[hazelcast.types.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.