Class PyList

All Implemented Interfaces:
Serializable, Iterable, Collection, List
Direct Known Subclasses:
PyListDerived

public class PyList extends PySequenceList
A builtin python list.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • classDictInit

      public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag
      Throws:
      PyIgnoreMethodTag
    • typeSetup

      public static void typeSetup(PyObject dict, PyType.Newstyle marker)
    • safeRepr

      public String safeRepr() throws PyIgnoreMethodTag
      Overrides:
      safeRepr in class PyObject
      Throws:
      PyIgnoreMethodTag
    • __len__

      public int __len__()
      Description copied from class: PyObject
      Equivalent to the standard Python __len__ method. Part of the mapping discipline.
      Overrides:
      __len__ in class PyObject
      Returns:
      the length of the object
    • __imul__

      public PyObject __imul__(PyObject o)
      Description copied from class: PyObject
      Equivalent to the standard Python __imul__ method
      Overrides:
      __imul__ in class PyObject
      Parameters:
      o - the object to perform this binary operation with (the right-hand operand).
      Returns:
      the result of the mul, or null if this operation is not defined
    • __add__

      public PyObject __add__(PyObject o)
      Description copied from class: PyObject
      Equivalent to the standard Python __add__ method
      Overrides:
      __add__ in class PyObject
      Parameters:
      o - the object to perform this binary operation with (the right-hand operand).
      Returns:
      the result of the add, or null if this operation is not defined
    • __radd__

      public PyObject __radd__(PyObject o)
      Description copied from class: PyObject
      Equivalent to the standard Python __radd__ method
      Overrides:
      __radd__ in class PyObject
      Parameters:
      o - the object to perform this binary operation with (the left-hand operand).
      Returns:
      the result of the add, or null if this operation is not defined.
    • toString

      public String toString()
      Overrides:
      toString in class PySequenceList
    • append

      public void append(PyObject o)
      Add a single element to the end of list.
      Parameters:
      o - the element to add.
    • count

      public int count(PyObject o)
      Return the number elements in the list that equals the argument.
      Parameters:
      o - the argument to test for. Testing is done with the == operator.
    • index

      public int index(PyObject o)
      return smallest index where an element in the list equals the argument.
      Parameters:
      o - the argument to test for. Testing is done with the == operator.
    • index

      public int index(PyObject o, int start)
    • index

      public int index(PyObject o, int start, int stop)
    • insert

      public void insert(int index, PyObject o)
      Insert the argument element into the list at the specified index.
      Same as s[index:index] = [o] if index >= 0.
      Parameters:
      index - the position where the element will be inserted.
      o - the element to insert.
    • remove

      public void remove(PyObject o)
      Remove the first occurence of the argument from the list. The elements arecompared with the == operator.
      Same as del s[s.index(x)]
      Parameters:
      o - the element to search for and remove.
    • reverse

      public void reverse()
      Reverses the items of s in place. The reverse() methods modify the list in place for economy of space when reversing a large list. It doesn't return the reversed list to remind you of this side effect.
    • pop

      public PyObject pop()
      Removes and return the last element in the list.
    • pop

      public PyObject pop(int n)
      Removes and return the n indexed element in the list.
      Parameters:
      n - the index of the element to remove and return.
    • extend

      public void extend(PyObject o)
      Append the elements in the argument sequence to the end of the list.
      Same as s[len(s):len(s)] = o.
      Parameters:
      o - the sequence of items to append to the list.
    • __iadd__

      public PyObject __iadd__(PyObject o)
      Description copied from class: PyObject
      Equivalent to the standard Python __iadd__ method
      Overrides:
      __iadd__ in class PyObject
      Parameters:
      o - the object to perform this binary operation with (the right-hand operand).
      Returns:
      the result of the add, or null if this operation is not defined
    • sort

      public void sort(PyObject compare)
      Sort the items of the list in place. The compare argument is a function of two arguments (list items) which should return -1, 0 or 1 depending on whether the first argument is considered smaller than, equal to, or larger than the second argument. Note that this slows the sorting process down considerably; e.g. to sort a list in reverse order it is much faster to use calls to the methods sort() and reverse() than to use the built-in function sort() with a comparison function that reverses the ordering of the elements.
      Parameters:
      compare - the comparison function.
    • sort

      public void sort()
      Sort the items of the list in place. Items is compared with the normal relative comparison operators.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection
      Specified by:
      hashCode in interface List
      Overrides:
      hashCode in class PySequenceList
    • __reduce__

      public PyObject __reduce__()
      Used for pickling.
      Overrides:
      __reduce__ in class PyObject
      Returns:
      a tuple of (class, tuple)
    • __getnewargs__

      public PyTuple __getnewargs__()
      Overrides:
      __getnewargs__ in class PyObject