Top Fields Constructors Methods
org.python.core

public abstract Class PySequenceList

extends PySequence
implements List, Traverseproc
Class Inheritance
All Implemented Interfaces
org.python.core.Traverseproc, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
org.python.core.PyTuple, org.python.core.PyList
Imports
java.util.Collection, .Iterator, .List, .ListIterator

Field Summary

Inherited from org.python.core.PySequence:
delegator

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract void
add(int
index at which the specified element is to be inserted
index
,
Object
element to be inserted
element
)

Redeclares java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).

public abstract boolean
add(Object
element to be appended to this list
o
)

Redeclares java.util.List.add.

Appends the specified element to the end of this list (optional operation).

public abstract boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<E>
collection containing elements to be added to this list
c
)

Redeclares java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).

public abstract boolean
addAll(Collection<E>
collection containing elements to be added to this list
c
)

Redeclares java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

public abstract void
clear()

Redeclares java.util.List.clear.

Removes all of the elements from this list (optional operation).

public abstract boolean
contains(Object
element whose presence in this list is to be tested
o
)

Redeclares java.util.List.contains.

Returns true if this list contains the specified element.

public abstract boolean
containsAll(Collection<E>
collection to be checked for containment in this list
c
)

Redeclares java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.

public abstract boolean
equals(Object
the object to be compared for equality with this list
o
)

Redeclares java.util.List.equals.

Overrides org.python.core.PyObject.equals.

Compares the specified object with this list for equality.

public abstract Object
get(int
index of the element to return
index
)

Redeclares java.util.List.get.

Returns the element at the specified position in this list.

public abstract PyObject[]
getArray()

Get the backing array.

public abstract int
hashCode()

Redeclares java.util.List.hashCode.

Overrides org.python.core.PyObject.hashCode.

Returns the hash code value for this list.

public abstract int
indexOf(Object
element to search for
o
)

Redeclares java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

public abstract boolean
isEmpty()

Redeclares java.util.List.isEmpty.

Returns true if this list contains no elements.

public abstract Iterator<E>
iterator()

Redeclares java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

public abstract int
lastIndexOf(Object
element to search for
o
)

Redeclares java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

public abstract ListIterator<E>
listIterator()

Redeclares java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

public abstract ListIterator<E>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Redeclares java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.

public abstract void
pyadd(int index, PyObject element)

public abstract boolean
public abstract PyObject
pyget(int
index of element to return.
index
)

Implements abstract org.python.core.PySequence.pyget.

Returns the element of the sequence at the given index.

public abstract void
pyset(int
index of the element to set.
index
,
PyObject
the value to set this element to.
element
)

Overrides org.python.core.PySequence.pyset.

Sets the indexed element of the sequence to the given value.

public boolean
public abstract Object
remove(int
the index of the element to be removed
index
)

Redeclares java.util.List.remove.

Removes the element at the specified position in this list (optional operation).

public abstract void
remove(int start, int stop)

public abstract boolean
remove(Object
element to be removed from this list, if present
o
)

Redeclares java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).

public abstract boolean
removeAll(Collection<E>
collection containing elements to be removed from this list
c
)

Redeclares java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

public abstract boolean
retainAll(Collection<E>
collection containing elements to be retained in this list
c
)

Redeclares java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).

public abstract Object
set(int
index of the element to replace
index
,
Object
element to be stored at the specified position
element
)

Redeclares java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

public abstract int
size()

Redeclares java.util.List.size.

Returns the number of elements in this list.

public abstract List<E>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Redeclares java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

public abstract Object[]
toArray()

Redeclares java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

public abstract Object[]
toArray(Object[]
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
)

Redeclares java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

public abstract String
toString()

Overrides org.python.core.PyObject.toString.

Returns a string representation of the object.

public int
traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.core.PySequence:
__delitem____delslice____eq____finditem____finditem____ge____getitem____getslice____gt____iter____le____lt____ne____nonzero____setitem____setitem____setslice____tojava__boundToSequencecmpdeldelRangedelslicefastSequencegetsliceisMappingTypeisNumberTypeisSequenceTypeisSubTyperepeatrunsupportedopMessageseq___delitem__seq___delslice__seq___eq__seq___finditem__seq___finditem__seq___ge__seq___getitem__seq___getslice__seq___gt__seq___iter__seq___le__seq___lt__seq___ne__seq___nonzero__seq___setitem__seq___setslice__setslicesliceLengthunsupportedopMessage

Constructor Detail

PySequenceListback to summary
protected PySequenceList(PyType type)

Method Detail

addback to summary
public abstract void add(int index, Object element)

Redeclares java.util.List.add.

Doc from java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
index:int

index at which the specified element is to be inserted

element:Object

element to be inserted

addback to summary
public abstract boolean add(Object o)

Redeclares java.util.List.add.

Doc from java.util.List.add.

Appends the specified element to the end of this list (optional operation).

Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.

Parameters
o:Object

element to be appended to this list

Returns:boolean

true (as specified by Collection#add)

addAllback to summary
public abstract boolean addAll(int index, Collection<E> c)

Redeclares java.util.List.addAll.

Doc from java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Parameters
index:int

index at which to insert the first element from the specified collection

c:Collection<E>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

addAllback to summary
public abstract boolean addAll(Collection<E> c)

Redeclares java.util.List.addAll.

Doc from java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Parameters
c:Collection<E>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

clearback to summary
public abstract void clear()

Redeclares java.util.List.clear.

Doc from java.util.List.clear.

Removes all of the elements from this list (optional operation). The list will be empty after this call returns.

containsback to summary
public abstract boolean contains(Object o)

Redeclares java.util.List.contains.

Doc from java.util.List.contains.

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e).

Parameters
o:Object

element whose presence in this list is to be tested

Returns:boolean

true if this list contains the specified element

containsAllback to summary
public abstract boolean containsAll(Collection<E> c)

Redeclares java.util.List.containsAll.

Doc from java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.

Parameters
c:Collection<E>

collection to be checked for containment in this list

Returns:boolean

true if this list contains all of the elements of the specified collection

equalsback to summary
public abstract boolean equals(Object o)

Redeclares java.util.List.equals.

Overrides org.python.core.PyObject.equals.

Doc from java.util.List.equals.

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if Objects.equals(e1, e2).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.

Parameters
o:Object

the object to be compared for equality with this list

Returns:boolean

true if the specified object is equal to this list

getback to summary
public abstract Object get(int index)

Redeclares java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Parameters
index:int

index of the element to return

Returns:Object

the element at the specified position in this list

getArrayback to summary
public abstract PyObject[] getArray()

Get the backing array. The array should not be modified. To get a copy of the array, see toArray().

hashCodeback to summary
public abstract int hashCode()

Redeclares java.util.List.hashCode.

Overrides org.python.core.PyObject.hashCode.

Doc from java.util.List.hashCode.

Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:

int hashCode = 1;
    for (E e : list)
        hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object#hashCode.
Returns:int

the hash code value for this list

indexOfback to summary
public abstract int indexOf(Object o)

Redeclares java.util.List.indexOf.

Doc from java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
o:Object

element to search for

Returns:int

the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element

isEmptyback to summary
public abstract boolean isEmpty()

Redeclares java.util.List.isEmpty.

Doc from java.util.List.isEmpty.

Returns true if this list contains no elements.

Returns:boolean

true if this list contains no elements

iteratorback to summary
public abstract Iterator<E> iterator()

Redeclares java.util.List.iterator.

Doc from java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

Returns:Iterator<E>

an iterator over the elements in this list in proper sequence

lastIndexOfback to summary
public abstract int lastIndexOf(Object o)

Redeclares java.util.List.lastIndexOf.

Doc from java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
o:Object

element to search for

Returns:int

the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element

listIteratorback to summary
public abstract ListIterator<E> listIterator()

Redeclares java.util.List.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

Returns:ListIterator<E>

a list iterator over the elements in this list (in proper sequence)

listIteratorback to summary
public abstract ListIterator<E> listIterator(int index)

Redeclares java.util.List.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

Parameters
index:int

index of the first element to be returned from the list iterator (by a call to next)

Returns:ListIterator<E>

a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list

pyaddback to summary
public abstract void pyadd(int index, PyObject element)
pyaddback to summary
public abstract boolean pyadd(PyObject o)
pygetback to summary
public abstract PyObject pyget(int index)

Implements abstract org.python.core.PySequence.pyget.

Doc from org.python.core.PySequence.pyget.

Returns the element of the sequence at the given index. This is an extension point called by PySequence in its implementation of __getitem__ It is guaranteed by PySequence that when it calls pyget(int) the index is within the bounds of the array. Any other clients must make the same guarantee.

Parameters
index:int

index of element to return.

Returns:PyObject

the element at the given position in the list.

pysetback to summary
public abstract void pyset(int index, PyObject element)

Overrides org.python.core.PySequence.pyset.

Doc from org.python.core.PySequence.pyset.

Sets the indexed element of the sequence to the given value. This is an extension point called by PySequence in its implementation of __setitem__ It is guaranteed by PySequence that when it calls pyset(int) the index is within the bounds of the array. Any other clients must make the same guarantee.

Parameters
index:int

index of the element to set.

element:PyObject

the value to set this element to.

refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob) throws UnsupportedOperationException

Implements org.python.core.Traverseproc.refersDirectlyTo.

Doc from org.python.core.Traverseproc.refersDirectlyTo.

Optional operation. Should only be implemented if it is more efficient than calling traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.

Annotations
@Override
removeback to summary
public abstract Object remove(int index)

Redeclares java.util.List.remove.

Doc from java.util.List.remove.

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters
index:int

the index of the element to be removed

Returns:Object

the element previously at the specified position

removeback to summary
public abstract void remove(int start, int stop)
removeback to summary
public abstract boolean remove(Object o)

Redeclares java.util.List.remove.

Doc from java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that Objects.equals(o, get(i)) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).

Parameters
o:Object

element to be removed from this list, if present

Returns:boolean

true if this list contained the specified element

removeAllback to summary
public abstract boolean removeAll(Collection<E> c)

Redeclares java.util.List.removeAll.

Doc from java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Parameters
c:Collection<E>

collection containing elements to be removed from this list

Returns:boolean

true if this list changed as a result of the call

retainAllback to summary
public abstract boolean retainAll(Collection<E> c)

Redeclares java.util.List.retainAll.

Doc from java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all of its elements that are not contained in the specified collection.

Parameters
c:Collection<E>

collection containing elements to be retained in this list

Returns:boolean

true if this list changed as a result of the call

setback to summary
public abstract Object set(int index, Object element)

Redeclares java.util.List.set.

Doc from java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

index of the element to replace

element:Object

element to be stored at the specified position

Returns:Object

the element previously at the specified position

sizeback to summary
public abstract int size()

Redeclares java.util.List.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

subListback to summary
public abstract List<E> subList(int fromIndex, int toIndex)

Redeclares java.util.List.subList.

Doc from java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

list.subList(from, to).clear();
Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList.

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

Parameters
fromIndex:int

low endpoint (inclusive) of the subList

toIndex:int

high endpoint (exclusive) of the subList

Returns:List<E>

a view of the specified range within this list

toArrayback to summary
public abstract Object[] toArray()

Redeclares java.util.List.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns:Object[]

an array containing all of the elements in this list in proper sequence

toArrayback to summary
public abstract Object[] toArray(Object[] a)

Redeclares java.util.List.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the list is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a list known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
a:Object[]

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.

Returns:Object[]

an array containing the elements of this list

toStringback to summary
public abstract String toString()

Overrides org.python.core.PyObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

traverseback to summary
public int traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Doc from org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc#visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc#visit(PyObject, Object) must not be called with a null PyObject-argument.

Annotations
@Override