abstract.h and with names
like: PySequence_*.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv abstract static class | PySequence.Delegate<
the element type returned by E, iterator().next()the slice type, and return type of
S>getSlice(Indices) etc..This is a helper class for implementations of sequence types. |
| public static interface | PySequence.Of<
the type of element returned by the iterators E>In the implementation of sequence types, it is useful to be able to create iterables and streams from their content. |
| public static interface | PySequence.OfInt
A specialisation of |
| Modifier and Type | Field and Description |
|---|---|
| protected static final String | |
| protected static final String | |
| private static final String | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static Object | |
| pack-priv static void | |
| pack-priv static < the type of exception to throw E extends PyException> List | |
| public static Object | |
| pack-priv static Object | |
| public static Object | |
| pack-priv static void | |
| public static int |
| DOES_NOT_SUPPORT_ITEM | back to summary |
|---|---|
| protected static final String DOES_NOT_SUPPORT_ITEM | |
| HAS_NO_LEN | back to summary |
|---|---|
| protected static final String HAS_NO_LEN | |
| NOT_SLICEABLE | back to summary |
|---|---|
| private static final String NOT_SLICEABLE | |
| NOT_SUBSCRIPTABLE | back to summary |
|---|---|
| private static final String NOT_SUBSCRIPTABLE | |
| PySequence | back to summary |
|---|---|
| protected PySequence() | |
| concat | back to summary |
|---|---|
| public static Object concat(Object v, Object w) throws Throwable
| |
| delItem | back to summary |
|---|---|
| pack-priv static void delItem(Object o, Object key) throws Throwable
| |
| fastList | back to summary |
|---|---|
| pack-priv static <E extends PyException> List Return the sequence or iterable
If the object is not a Python sequence (defines
the iterable or its contents as a list
| |
| getItem | back to summary |
|---|---|
| public static Object getItem(Object o, Object key) throws Throwable
| |
| getSlice | back to summary |
|---|---|
| pack-priv static Object getSlice(Object o, int i1, int i2) throws Throwable
| |
| repeat | back to summary |
|---|---|
| public static Object repeat(Object o, int count) throws Throwable
| |
| setItem | back to summary |
|---|---|
| pack-priv static void setItem(Object o, Object key, Object value) throws Throwable
| |
| size | back to summary |
|---|---|
| public static int size(Object o) throws Throwable
| |
iterator().next()
getSlice(Indices) etc..
Delegate, to which it delegates certain
operations. This sub-class could be an inner class with access to
private members and methods of the client.
Delegate declares abstract or overridable methods
representing elementary operations on the client sequence (to
get, set or delete an element or slice, or to enquire its length
or type). It offers methods based on these that are usable
implementations of the Python special methods
__getitem__, __setitem__, __delitem__,
__add__ and __mul__. It provides the boiler-plate
that tends to be the same from one Python type to another –
recognition that an index is a slice, end-relative addressing,
index type and range checks, and the raising of index-related
Python exceptions. (For examples of this similarity, compare the
CPython implementation of list_subscript with that of
bytes_subscript or any other *_subscript method.)
The client must override abstract methods declared here, in the
delegate sub-class it defines, to specialise the behaviour. A
sub-class supporting a mutable sequence type must additionally
override setItem(int, Object),
setSlice(Indices, Object) and
delSlice(Indices). It may also override
delItem(int), or rely on the default implementation
using delSlice.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object | Returns: self+w or NotImplementedright operand w)Implementation of |
| public void | |
| public Object | Returns: the element or slice(or slice) to get from in the client item)Implementation of |
| pack-priv Object | Returns: self*n or NotImplementednumber of repetitions in result n)Implementation of |
| pack-priv Object | Returns: v+self or NotImplementedleft operand v)Implementation of |
| public void | __setitem__(Object
(or slice) to assign in the client item, Object to assign value)Implementation of |
| pack-priv abstract Object | add(Object
the right operand ow)Inner implementation of |
| protected int | |
| protected int | |
| protected int | Returns: converted indexpurported index (or index, int null)to use if defaultValue)index==nullAccept an object index (or |
| private OverflowError | Returns: an exception to throwAn overflow error with the message "concatenated
|
| public void | delItem(int
index of item to delete i)Inner implementation of |
| public void | delSlice(PySlice.
containing [start, stop, step, count] of the slice
to delete sliceInner implementation of |
| public abstract Object | Returns: the element from the client sequenceindex of item to return i)Inner implementation of |
| public abstract S | Returns: the slice from the client sequencecontaining [start, stop, step, count] of the slice
to return sliceInner implementation of |
| public abstract PyType | Returns: the type of client sequenceProvide the type of client sequence, primarily for use in error messages e.g. "TYPE index out of bounds". |
| public String | Returns: the name of Python type being servedReturn the name of the Python type of the client sequence. |
| public int | |
| public abstract int | Returns: the length of the client sequenceRedeclares org. |
| pack-priv abstract Object | radd(Object
the left operand ov)Inner implementation of |
| protected final IndexError | Returns: an exception to throwword to insert for KIND: "" or "assignment". kind)Creates an |
| pack-priv abstract S | Returns: repetitionself*nthe number of repetitions n)Inner implementation of |
| private OverflowError | Returns: an exception to throwAn overflow error with the message "repeated S is too long", where S is the type mane of the argument. |
| public void | setItem(int
index of item to set i, Object to set at value)iInner implementation of |
| public void |
| Delegate | back to summary |
|---|---|
| pack-priv Delegate() | |
| __add__ | back to summary |
|---|---|
| pack-priv Object __add__(Object w) throws OverflowError, Throwable Implementation of
The wrapper attempts no conversion of the argument, but it will
catch
| |
| __delitem__ | back to summary |
|---|---|
| public void __delitem__(Object item) throws TypeError, Throwable Implementation of
| |
| __getitem__ | back to summary |
|---|---|
| public Object __getitem__(Object item) throws TypeError, Throwable Implementation of
| |
| __mul__ | back to summary |
|---|---|
| pack-priv Object __mul__(Object n) throws TypeError, Throwable Implementation of
The wrapper attempts conversion of the argument to
| |
| __radd__ | back to summary |
|---|---|
| pack-priv Object __radd__(Object v) throws OverflowError, Throwable Implementation of
The wrapper attempts no conversion of the argument, but it will
catch
| |
| __setitem__ | back to summary |
|---|---|
| public void __setitem__(Object item, Object value) throws TypeError, Throwable Implementation of
| |
| add | back to summary |
|---|---|
| pack-priv abstract Object add(Object ow) throws OutOfMemoryError, NoConversion, Throwable Inner implementation of
The implementation of this method is responsible for validating
the argument. If an
| |
| adjustGet | back to summary |
|---|---|
| protected int adjustGet(int i) Check that an index
| |
| adjustSet | back to summary |
|---|---|
| protected int adjustSet(int i) throws IndexError Check that an index
| |
| boundedIndex | back to summary |
|---|---|
| protected int boundedIndex(Object index, int defaultValue) throws TypeError, Throwable Accept an object index (or
converted index | |
| concatOverflow | back to summary |
|---|---|
| private OverflowError concatOverflow() An overflow error with the message "concatenated
| |
| delItem | back to summary |
|---|---|
| public void delItem(int i) throws Throwable Inner implementation of
The default implementation deletes a slice
| |
| delSlice | back to summary |
|---|---|
| public void delSlice(PySlice. Inner implementation of In mutable types, override this to delete the given slice of the client sequence. The default implementation (for immutable types) does nothing. | |
| getItem | back to summary |
|---|---|
| public abstract Object getItem(int i) throws Throwable Inner implementation of | |
| getSlice | back to summary |
|---|---|
| public abstract S getSlice(PySlice. Inner implementation of | |
| getType | back to summary |
|---|---|
| public abstract PyType getType() Provide the type of client sequence, primarily for use in error messages e.g. "TYPE index out of bounds". Implementation Note This can simply return a constant characteristic of the
the implementing class, the Python type implements or
supports. E.g the adaptor for a Java String returns
| |
| getTypeName | back to summary |
|---|---|
| public String getTypeName() Return the name of the Python type of the client sequence. This
is used in exception messages generated here. By default this is
| |
| index | back to summary |
|---|---|
| public int index(Object v, Object start, Object stop) throws TypeError, ValueError, Throwable Implementation of the
the index at which found
| |
| length | back to summary |
|---|---|
| public abstract int length() Redeclares org. Returns the length of the client sequence from the perspective of indexing and slicing operations.
| |
| radd | back to summary |
|---|---|
| pack-priv abstract Object radd(Object ov) throws OutOfMemoryError, NoConversion, Throwable Inner implementation of
The implementation of this method is responsible for validating
the argument. If an
| |
| rangeIndexError | back to summary |
|---|---|
| protected final IndexError rangeIndexError(String kind) Creates an
| |
| repeat | back to summary |
|---|---|
| pack-priv abstract S repeat(int n) throws OutOfMemoryError, Throwable Inner implementation of
| |
| repeatOverflow | back to summary |
|---|---|
| private OverflowError repeatOverflow() An overflow error with the message "repeated S is too long", where S is the type mane of the argument.
| |
| setItem | back to summary |
|---|---|
| public void setItem(int i, Object value) throws Throwable Inner implementation of In mutable types, override this to assign a value to the given element of the client sequence. The default implementation (for immutable types) does nothing.
| |
| setSlice | back to summary |
|---|---|
| public void setSlice(PySlice. Inner implementation of In mutable types, override this to assign a value to the given slice of the client sequence. The default implementation (for immutable types) does nothing.
| |
Delegate
implementations in the core also provide this interface.
| Modifier and Type | Method and Description |
|---|---|
| public default Stream | |
| public E | |
| public int | |
| public default Spliterator | spliterator()
Overrides default java. Spliterator over the elements described by this
Iterable.
|
| asStream | back to summary |
|---|---|
public default Stream
| |
| get | back to summary |
|---|---|
| public E get(int i) Get an item from the sequence at a given index
| |
| length | back to summary |
|---|---|
| public int length() The length of this sequence.
| |
| spliterator | back to summary |
|---|---|
| public default Spliterator Overrides default java. Doc from java. Creates a
| |
PySequence.Of<Integer> where
the elements may be consumed as primitive int.
| Modifier and Type | Method and Description |
|---|---|
| public IntStream | |
| public default Stream | |
| public default Integer | get(int
index i)Implements org. i.
|
| public int | |
| public Spliterator. | spliterator()
Redeclares as abstract: org. Spliterator over the elements described by this
Iterable.
|
| asIntStream | back to summary |
|---|---|
| public IntStream asIntStream() Provide a stream specialised to primitive
| |
| asStream | back to summary |
|---|---|
| public default Stream Overrides default org. Implementation Note The default implementation is the stream of values from
| |
| get | back to summary |
|---|---|
| public default Integer get(int i) Implements org. Doc from org. Get an item from the sequence at a given index | |
| getInt | back to summary |
|---|---|
| public int getInt(int i) Get the int item from the sequence at a given index
| |
| spliterator | back to summary |
|---|---|
| public Spliterator. Redeclares as abstract: org. Doc from org. Creates a
| |