List¶
-
class
List
(service_name, name, context)¶ Bases:
hazelcast.proxy.base.PartitionSpecificProxy
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)¶ 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.- Return type
hazelcast.future.Future[bool]
-
add_at
(index, item)¶ 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 (int) – The specified index to insert the item.
item – The specified item to be inserted.
- Returns
- Return type
hazelcast.future.Future[None]
-
add_all
(items)¶ 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 (list) – The specified collection which includes the elements to be added to list.
- Returns
True
if this call changed the list,False
otherwise.- Return type
hazelcast.future.Future[bool]
-
add_all_at
(index, items)¶ 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 (int) – The specified index at which the first element of specified collection is added.
items (list) – The specified collection which includes the elements to be added to list.
- Returns
True
if this call changed the list,False
otherwise.- Return type
hazelcast.future.Future[bool]
-
add_listener
(include_value=False, item_added_func=None, item_removed_func=None)¶ Adds an item listener for this list. Listener will be notified for all list add/remove events.
- Parameters
include_value (bool) – Whether received events include the updated item or not.
item_added_func (function) – To be called when an item is added to this list.
item_removed_func (function) – 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.
- Return type
-
clear
()¶ Clears the list.
List will be empty with this call.
- Returns
- Return type
hazelcast.future.Future[None]
-
contains
(item)¶ 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.- Return type
hazelcast.future.Future[bool]
-
contains_all
(items)¶ Determines whether this list contains all of the items in specified collection or not.
- Parameters
items (list) – The specified collection which includes the items to be searched.
- Returns
True
if all of the items in specified collectionexist in this list,
False
otherwise.
- Return type
hazelcast.future.Future[bool]
-
get
(index)¶ Returns the item which is in the specified position in this list.
- Parameters
index (int) – the specified index of the item to be returned.
- Returns
the item in the specified position in this list.
- Return type
-
get_all
()¶ Returns all of the items in this list.
- Returns
All of the items in this list.
- Return type
hazelcast.future.Future[list]
-
iterator
()¶ Returns an iterator over the elements in this list in proper sequence, same with
get_all
.- Returns
All of the items in this list.
- Return type
hazelcast.future.Future[list]
-
index_of
(item)¶ Returns the first index of specified items’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 items’s occurrences,
-1 if item is not present in this list.
- Return type
-
is_empty
()¶ Determines whether this list is empty or not.
- Returns
True
if the list contains no elements,False
otherwise.- Return type
hazelcast.future.Future[bool]
-
last_index_of
(item)¶ Returns the last index of specified items’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 items’s occurrences,
-1 if item is not present in this list.
- Return type
-
list_iterator
(index=0)¶ Returns a list iterator of the elements in this list.
If an index is provided, iterator starts from this index.
- Parameters
index – (int), index of first element to be returned from the list iterator.
- Returns
List of the elements in this list.
- Return type
hazelcast.future.Future[list]
-
remove
(item)¶ 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.
- Return type
hazelcast.future.Future[bool]
-
remove_at
(index)¶ 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 (int) – Index of the item to be removed.
- Returns
The item previously at the specified index.
- Return type
-
remove_all
(items)¶ Removes all of the elements that is present in the specified collection from this list.
- Parameters
items (list) – The specified collection.
- Returns
True
if this list changed as a result of the call,False
otherwise.- Return type
hazelcast.future.Future[bool]
-
remove_listener
(registration_id)¶ Removes the specified item listener.
Returns silently if the specified listener was not added before.
- Parameters
registration_id (str) – Id of the listener to be deleted.
- Returns
True
if the item listener is removed,False
otherwise.- Return type
hazelcast.future.Future[bool]
-
retain_all
(items)¶ 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 (list) – 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.- Return type
hazelcast.future.Future[bool]
-
size
()¶ Returns the number of elements in this list.
- Returns
Number of elements in this list.
- Return type
-
set_at
(index, item)¶ Replaces the specified element with the element at the specified position in this list.
- Parameters
index (int) – Index of the item to be replaced.
item – Item to be stored.
- Returns
the previous item in the specified index.
- Return type
-
sub_list
(from_index, to_index)¶ 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 (int) – The start point(inclusive) of the sub_list.
to_index (int) – The end point(exclusive) of the sub_list.
- Returns
A view of the specified range within this list.
- Return type
hazelcast.future.Future[list]
-