list
object that is also a Java
List<Object>
. Operations in both APIs are synchronised
for safety against concurrent threads.
It is synchronized
so that competing threads should be
able to access it with roughly the same protection against
concurrent modification that CPython offers. There are also
necessary safeguards during sort()
to detect modification
from within the current thread as a side effect of comparison.
Java brings its own safeguard within iterators against structural
concurrent modification.
Implementation Note
The design follows that in Jython 2 with a private Java list member to which operations are delegated directly or indirectly. In the present design, the indirect delegation is through a private delegate member where in the former design behaviour was inherited.
Modifier and Type | Class and Description |
---|---|
private static class | PyList.KV
During |
private class | PyList.ListDelegate
Wrap the |
private abstract class | PyList.ListElementComparator<
type of element to sort (on practice T>Object or
KV .This comparator is used in
|
Modifier and Type | Field and Description |
---|---|
private boolean | changed
Synchronisation prevents modification by competing threads during an operation, but does not defend against actions within that operation by the same thread. |
private final PyList. | delegate
Implementation help for sequence methods. |
private final List | list
Storage for the actual list elements (as a list). |
public static final PyType | |
protected final PyType | type
The Python type of this instance. |
Access | Constructor and Description |
---|---|
private | |
public | |
public | |
public | |
public | |
public | PyList(PyType
actual type type, Collection<?> initial contents c)Construct a Python |
public | |
pack-priv |
Modifier and Type | Method and Description |
---|---|
pack-priv synchronized Object | |
pack-priv synchronized boolean | |
pack-priv synchronized void | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
public PyTuple | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized int | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized Object | |
pack-priv synchronized void | |
public synchronized void | add(int
index at which the specified element is to be inserted index, Object element to be inserted element)Implements java. |
public synchronized boolean | add(Object
element to be appended to this list o)Implements java. |
public synchronized boolean | addAll(int
index at which to insert the first element from the
specified collection index, Collection<?> collection containing elements to be added to this list c)Implements java. |
public boolean | addAll(Collection<?>
collection containing elements to be added to this list c)Implements java. |
private int | Returns: bounded0 <= index <= list.size() as presented index)Accept an index, treating negative values as end-relative, and bound it to the sequence range. |
public synchronized void | clear()
Implements java. |
private static PyList | |
public synchronized boolean | contains(Object
element whose presence in this list is to be tested o)Implements java. true if this list contains the specified element.
|
public synchronized boolean | containsAll(Collection<?>
collection to be checked for containment in this list c)Implements java. true if this list contains all of the elements of the
specified collection.
|
public boolean | equals(Object
the object to be compared for equality with this list other)Overrides java. Implements java. |
private boolean | |
private int | |
public synchronized Object | get(int
index of the element to return index)Implements java. |
public PyType | |
public int | hashCode()
Overrides java. Implements java. |
public synchronized int | indexOf(Object
element to search for o)Implements java. |
public synchronized boolean | |
public Iterator | iterator()
Implements java. |
public synchronized int | lastIndexOf(Object
element to search for o)Implements java. |
pack-priv final synchronized void | |
pack-priv final synchronized void | |
pack-priv final synchronized int | Returns: the number of occurrences.the value to test for. v)Return the number elements in the list that are Python-equal to the argument. |
pack-priv final synchronized void | list_extend(Object
the sequence of items to append to the list. o)Append the elements in the argument sequence to the end of the
list, |
pack-priv final < the type of exception to throw E extends PyException> void | list_extend(Object
the sequence of items to append to the list. o, Supplier<E> a supplier (e.g. lambda expression) for the exception
to throw if an iterator cannot be formed (or exc)null for
a default TypeError )Append the elements in the argument sequence to the end of the
list, |
pack-priv final synchronized int | Returns: index of the occurrencethe value to look for. v, Object first index to test start, Object first index not to test stop)Return smallest index where an element in the list Python-equals the argument. |
pack-priv final synchronized void | list_insert(Object
the position where the element will be inserted. index, Object the element to insert. o)Insert the argument element into the list at the specified index. |
pack-priv final synchronized Object | Returns: the popped itemthe index of the element to remove and return. n)Remove and return a specified element from the list. |
pack-priv final synchronized void | list_remove(Object
the element to search for and remove. v)Remove from the list the first element that is Python-equal to the argument. |
public ListIterator | listIterator()
Implements java. |
public ListIterator | listIterator(final int
index of the first element to be returned from the
list iterator (by a call to index)next )Implements java. |
public static PyList | Returns: list of elementsinitial element values elements)Hides java. list object, specifying initial
contents.
|
public synchronized Object | remove(int
the index of the element to be removed index)Implements java. |
public synchronized boolean | remove(Object
element to be removed from this list, if present o)Implements java. |
public synchronized boolean | removeAll(Collection<?>
collection containing elements to be removed from this list c)Implements java. |
public synchronized boolean | retainAll(Collection<?>
collection containing elements to be retained in this list c)Implements java. |
pack-priv final synchronized void | |
public synchronized Object | set(int
index of the element to replace index, Object element to be stored at the specified position element)Implements java. |
public synchronized int | |
pack-priv final synchronized void | sort(Function<Object, Object>
specifies a function of one argument that is used to
extract a comparison key from each list element, e.g.
key, boolean key=str.lower . The default value is None .the list elements are sorted as if each comparison
were reversed. reverse)Sort the items of the list in place, using only < comparisons between items. |
private synchronized void | |
private synchronized void | |
public synchronized List | subList(int
low endpoint (inclusive) of the subList fromIndex, int high endpoint (exclusive) of the subList toIndex)Implements java. fromIndex , inclusive, and toIndex , exclusive.
|
public synchronized Object[] | toArray()
Implements java. |
public synchronized <T> T[] | toArray(T[]
the array into which the elements of this list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose. a)Implements java. |
public String |