Top Description Inners Fields Constructors Methods
org.python.core

public Class PySequence

extends Abstract
Class Inheritance
Known Direct Subclasses
org.python.core.PyMapping
Imports
java.util.List, .Spliterator, .Spliterators, java.util.function.Supplier, java.util.stream.IntStream, .Stream, .StreamSupport, org.python.base.MissingFeature, org.python.core.PyObjectUtil.NoConversion, .PySlice.Indices, .Slot.EmptyException

Abstract API for operations on sequence types, corresponding to CPython methods defined in abstract.h and with names like: PySequence_*.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract static class
PySequence.Delegate<
the element type returned by iterator().next()
E
,
the slice type, and return type of getSlice(Indices) etc..
S
>

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 PySequence.

Field Summary

Modifier and TypeField and Description
protected static final String
protected static final String
private static final String
private static final String
Inherited from org.python.core.Abstract:
NOT_ITERABLENOT_MAPPING

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static Object

Returns:

v + w
concat
(Object
first object to concatenate
v
,
Object
second object to concatenate
w
)

v + w for sequences with Python semantics.

pack-priv static void
delItem(Object
object to operate on
o
,
Object
index at which to delete element
key
)

del o[key] with Python semantics, where o may be a mapping or a sequence.

pack-priv static <
the type of exception to throw
E extends PyException
>
List<Object>

Returns:

the iterable or its contents as a list
fastList
(Object
to present as a list
o
,
Supplier<E>
a supplier (e.g. lambda expression) for the exception
exc
)

Return the sequence or iterable o as a Java List.

public static Object

Returns:

o[key]
getItem
(Object
object to operate on
o
,
Object
index
key
)

o[key] with Python semantics, where o may be a mapping or a sequence.

pack-priv static Object

Returns:

o[i1:i2]
getSlice
(Object
sequence to operate on
o
,
int
index of first item in slice
i1
,
int
index of first item not in slice
i2
)

o[i1:12] with Python semantics, where o must be a sequence.

public static Object

Returns:

o*count
repeat
(Object
object to operate on
o
,
int
number of repetitions
count
)

o * count with Python semantics.

pack-priv static void
setItem(Object
object to operate on
o
,
Object
index
key
,
Object
to put at index
value
)

o[key] = value with Python semantics, where o may be a mapping or a sequence.

public static int

Returns:

len(o)
size
(Object
object to operate on
o
)

len(o) with Python semantics.

Inherited from org.python.core.Abstract:
argumentTypeErrorargumentTypeErrorattributeNameTypeErrorattrMustBeattrMustBeStringbadInternalCallcantSetAttributeErrordelAttrdelAttrgetAttrgetAttrgetIteratorgetIteratorhashimpossibleArgumentErrorindexOutOfRangeindexTypeErrorindexTypeErrorisTrueiterableCheckiteratorChecklookupAttrlookupAttrmandatoryAttributeErrormandatoryAttributeOnTypenextnoAttributeErrornoAttributeOnTypereadonlyAttributeErrorreadonlyAttributeOnTyperecursiveIsSubclassreprrequiredTypeErrorreturnDeprecationreturnTypeErrorrichComparerichCompareBoolrichCompareBoolsetAttrsetAttrstrtojavatypeError

Field Detail

DOES_NOT_SUPPORT_ITEMback to summary
protected static final String DOES_NOT_SUPPORT_ITEM
HAS_NO_LENback to summary
protected static final String HAS_NO_LEN
NOT_SLICEABLEback to summary
private static final String NOT_SLICEABLE
NOT_SUBSCRIPTABLEback to summary
private static final String NOT_SUBSCRIPTABLE

Constructor Detail

PySequenceback to summary
protected PySequence()

Method Detail

concatback to summary
public static Object concat(Object v, Object w) throws Throwable

v + w for sequences with Python semantics.

Parameters
v:Object

first object to concatenate

w:Object

second object to concatenate

Returns:Object

v + w

Exceptions
Throwable:
from invoked method implementations

delItemback to summary
pack-priv static void delItem(Object o, Object key) throws Throwable

del o[key] with Python semantics, where o may be a mapping or a sequence.

Parameters
o:Object

object to operate on

key:Object

index at which to delete element

Exceptions
Throwable:
from invoked method implementations
TypeError:
when o does not allow subscripting
fastListback to summary
pack-priv static <E extends PyException> List<Object> fastList(Object o, Supplier<E> exc) throws Supplier-:E, Throwable

Return the sequence or iterable o as a Java List. If o is one of several built-in types that implement Java List<Object>, this will be the object itself. Otherwise, it will be a copy in a Java list that supports efficient random access.

If the object is not a Python sequence (defines __getitem__) or Python iterable (defines __iter__), call exc to raise an exception (typically a TypeError).

Parameters
<E>
the type of exception to throw
o:Object

to present as a list

exc:Supplier<E>

a supplier (e.g. lambda expression) for the exception

Returns:List<Object>

the iterable or its contents as a list

Exceptions
Supplier-:E:
to throw if an iterator cannot be formed
Throwable:
from the implementation of o.

getItemback to summary
public static Object getItem(Object o, Object key) throws Throwable

o[key] with Python semantics, where o may be a mapping or a sequence.

Parameters
o:Object

object to operate on

key:Object

index

Returns:Object

o[key]

Exceptions
Throwable:
from invoked method implementations
TypeError:
when o does not allow subscripting

getSliceback to summary
pack-priv static Object getSlice(Object o, int i1, int i2) throws Throwable

o[i1:12] with Python semantics, where o must be a sequence. Receiving objects will normally interpret indices as end-relative, and bounded to the sequence length.

Parameters
o:Object

sequence to operate on

i1:int

index of first item in slice

i2:int

index of first item not in slice

Returns:Object

o[i1:i2]

Exceptions
Throwable:
from invoked method implementations
TypeError:
when o does not allow subscripting

repeatback to summary
public static Object repeat(Object o, int count) throws Throwable

o * count with Python semantics.

Parameters
o:Object

object to operate on

count:int

number of repetitions

Returns:Object

o*count

Exceptions
Throwable:
from invoked method implementations

setItemback to summary
pack-priv static void setItem(Object o, Object key, Object value) throws Throwable

o[key] = value with Python semantics, where o may be a mapping or a sequence.

Parameters
o:Object

object to operate on

key:Object

index

value:Object

to put at index

Exceptions
Throwable:
from invoked method implementations
TypeError:
when o does not allow subscripting
sizeback to summary
public static int size(Object o) throws Throwable

len(o) with Python semantics.

Parameters
o:Object

object to operate on

Returns:int

len(o)

Exceptions
Throwable:
from invoked method implementations

org.python.core back to summary

pack-priv abstract Class PySequence.Delegate<E, S>

extends Object
implements PySequence.Of<E>, Comparable<PySequence.Delegate<E, S>>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, org.python.core.PySequence.Of, java.lang.Iterable
Known Direct Subclasses
org.python.core.PyTuple.TupleDelegate, org.python.core.PyUnicode.CodepointDelegate, org.python.core.PyBytes.BytesDelegate, org.python.core.PyList.ListDelegate
Type Parameters
<E>
the element type returned by iterator().next()
<S>
the slice type, and return type of getSlice(Indices) etc..

This is a helper class for implementations of sequence types. A client sequence implementation may hold an instance of a sub-class of 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.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Object

Returns:

self+w or NotImplemented
__add__
(Object
right operand
w
)

Implementation of __add__ (concatenation) by calling add(Object).

public void
__delitem__(Object
(or slice) to delete in the client
item
)

Implementation of __delitem__.

public Object

Returns:

the element or slice
__getitem__
(Object
(or slice) to get from in the client
item
)

Implementation of __getitem__.

pack-priv Object

Returns:

self*n or NotImplemented
__mul__
(Object
number of repetitions in result
n
)

Implementation of __mul__ (repetition) and __rmul__ by calling repeat(int).

pack-priv Object

Returns:

v+self or NotImplemented
__radd__
(Object
left operand
v
)

Implementation of __radd__ (reflected concatenation) by calling radd(Object).

public void
__setitem__(Object
(or slice) to assign in the client
item
,
Object
to assign
value
)

Implementation of __setitem__.

pack-priv abstract Object

Returns:

concatenation self+ow or Py#NotImplemented
add
(Object
the right operand
ow
)

Inner implementation of __add__ on the client sequence, called by __add__(Object).

protected int

Returns:

range-checked i
adjustGet
(int
to check is valid index
i
)

Check that an index i satisfies 0≤i<length().

protected int

Returns:

range-checked i
adjustSet
(int
to check is valid index
i
)

Check that an index i satisfies 0≤i<length().

protected int

Returns:

converted index
boundedIndex
(Object
purported index (or null)
index
,
int
to use if index==null
defaultValue
)

Accept an object index (or null), treating negative values as end-relative, and bound it to the sequence range.

private OverflowError

Returns:

an exception to throw
concatOverflow
()

An overflow error with the message "concatenated getTypeName() is too long", involving the type name of the client sequence type.

public void
delItem(int
index of item to delete
i
)

Inner implementation of __delitem__, called by __setitem__(Object, Object) when its argument is an integer.

public void
delSlice(PySlice.Indices
containing [start, stop, step, count] of the slice to delete
slice
)

Inner implementation of __delitem__, called by __delitem__(Object) when its argument is a PySlice.

public abstract Object

Returns:

the element from the client sequence
getItem
(int
index of item to return
i
)

Inner implementation of __getitem__, called by __getitem__(Object) when its argument is an integer.

public abstract S

Returns:

the slice from the client sequence
getSlice
(PySlice.Indices
containing [start, stop, step, count] of the slice to return
slice
)

Inner implementation of __getitem__, called by __getitem__(Object) when its argument is a PySlice.

public abstract PyType

Returns:

the type of client sequence
getType
()

Provide 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 served
getTypeName
()

Return the name of the Python type of the client sequence.

public int

Returns:

the index at which found
index
(Object
value to match in the client
v
,
Object
index of first element in range
start
,
Object
index of first element not in range
stop
)

Implementation of the index method of sequences.

public abstract int

Returns:

the length of the client sequence
length
()

Redeclares org.python.core.PySequence.Of.length.

Returns the length of the client sequence from the perspective of indexing and slicing operations.
pack-priv abstract Object

Returns:

concatenation ov+self or Py#NotImplemented
radd
(Object
the left operand
ov
)

Inner implementation of __radd__ on the client sequence, called by __radd__(Object).

protected final IndexError

Returns:

an exception to throw
rangeIndexError
(String
word to insert for KIND: "" or "assignment".
kind
)

Creates an IndexError with the message "getTypeName() KIND index out of range", e.g. "list assignment index out of range".

pack-priv abstract S

Returns:

repetition self*n
repeat
(int
the number of repetitions
n
)

Inner implementation of __mul__ on the client sequence, called by __mul__(Object).

private OverflowError

Returns:

an exception to throw
repeatOverflow
()

An 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 i
value
)

Inner implementation of __setitem__, called by __setitem__(Object, Object) when its argument is an integer.

public void
setSlice(PySlice.Indices
to assign in the client sequence
slice
,
Object
to assign
value
)

Inner implementation of __setitem__, called by __setitem__(Object, Object) when its argument is a PySlice.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Delegateback to summary
pack-priv Delegate()

Method Detail

__add__back to summary
pack-priv Object __add__(Object w) throws OverflowError, Throwable

Implementation of __add__ (concatenation) by calling add(Object).

The wrapper attempts no conversion of the argument, but it will catch NoConversion exceptions from add(Object), to return NotImplemented. It will also catch Java OutOfMemoryError and convert it to a Python OverflowError.

Parameters
w:Object

right operand

Returns:Object

self+w or NotImplemented

Exceptions
OverflowError:
when cannot allocate space
Throwable:
from other causes in the implementation.

__delitem__back to summary
public void __delitem__(Object item) throws TypeError, Throwable

Implementation of __delitem__. Delete either an element or a slice of the client sequence, after checks, by calling either delItem(int) or delSlice(Indices).

Parameters
item:Object

(or slice) to delete in the client

Exceptions
TypeError:
from bad slice index types
Throwable:
from errors other than indexing
ValueError:
if slice.step==0 or value is the wrong length in an extended slice (slice.step!=1
__getitem__back to summary
public Object __getitem__(Object item) throws TypeError, Throwable

Implementation of __getitem__. Get either an element or a slice of the client sequence, after checks, by calling either getItem(int) or getSlice(Indices).

Parameters
item:Object

(or slice) to get from in the client

Returns:Object

the element or slice

Exceptions
TypeError:
from bad slice index types
Throwable:
from errors other than indexing
ValueError:
if slice.step==0

__mul__back to summary
pack-priv Object __mul__(Object n) throws TypeError, Throwable

Implementation of __mul__ (repetition) and __rmul__ by calling repeat(int).

The wrapper attempts conversion of the argument to int, and if this cannot be achieved, it will return NotImplemented. It will also catch Java OutOfMemoryError and convert it to a Python OverflowError.

Parameters
n:Object

number of repetitions in result

Returns:Object

self*n or NotImplemented

Exceptions
TypeError:
if n has no __index__
Throwable:
from implementation of __index__, or other causes in the implementation.
OverflowError:
when n over-size or cannot allocate space

__radd__back to summary
pack-priv Object __radd__(Object v) throws OverflowError, Throwable

Implementation of __radd__ (reflected concatenation) by calling radd(Object).

The wrapper attempts no conversion of the argument, but it will catch NoConversion exceptions from radd(Object), to return NotImplemented. It will also catch Java OutOfMemoryError and convert it to a Python OverflowError.

Parameters
v:Object

left operand

Returns:Object

v+self or NotImplemented

Exceptions
OverflowError:
when cannot allocate space
Throwable:
from other causes in the implementation.

__setitem__back to summary
public void __setitem__(Object item, Object value) throws TypeError, Throwable

Implementation of __setitem__. Assign a value to either an element or a slice of the client sequence, after checks, by calling either setItem(int, Object) or setSlice(Indices, Object).

Parameters
item:Object

(or slice) to assign in the client

value:Object

to assign

Exceptions
TypeError:
from bad slice index types
Throwable:
from errors other than indexing
ValueError:
if slice.step==0 or slice.step!=1 (an "extended" slice) and value is the wrong length.
addback to summary
pack-priv abstract Object add(Object ow) throws OutOfMemoryError, NoConversion, Throwable

Inner implementation of __add__ on the client sequence, called by __add__(Object).

The implementation of this method is responsible for validating the argument. If an __add__ is being attempted between incompatible types it should return Py#NotImplemented, or throw a NoConversion exception, which will cause __add__ to return NotImplemented.

Parameters
ow:Object

the right operand

Returns:Object

concatenation self+ow or Py#NotImplemented

Exceptions
OutOfMemoryError:
when allocating the result fails. __add__ will raise a Python OverflowError.
NoConversion:
(optionally) when the client does not support the type of ow.
Throwable:
from other causes in the implementation

adjustGetback to summary
protected int adjustGet(int i)

Check that an index i satisfies 0≤i<length(). If the original index is negative, treat it as end-relative by first adding length().

Parameters
i:int

to check is valid index

Returns:int

range-checked i

Exceptions
IndexError:
if i out of range

adjustSetback to summary
protected int adjustSet(int i) throws IndexError

Check that an index i satisfies 0≤i<length(). If the original index is negative, treat it as end-relative by first adding length(). This differs from adjustGet(int) only in that the message produced mentions "assignment".

Parameters
i:int

to check is valid index

Returns:int

range-checked i

Exceptions
IndexError:
if i out of range

boundedIndexback to summary
protected int boundedIndex(Object index, int defaultValue) throws TypeError, Throwable

Accept an object index (or null), treating negative values as end-relative, and bound it to the sequence range. The index object must be convertible by PyNumber.asSize. Unlike adjustGet(int), is not an error for the index value to fall outside the valid range. (It is simply clipped to the nearer end.)

Parameters
index:Object

purported index (or null)

defaultValue:int

to use if index==null

Returns:int

converted index

Exceptions
TypeError:
from bad index type
Throwable:
from other conversion errors

concatOverflowback to summary
private OverflowError concatOverflow()

An overflow error with the message "concatenated getTypeName() is too long", involving the type name of the client sequence type.

Returns:OverflowError

an exception to throw

delItemback to summary
public void delItem(int i) throws Throwable

Inner implementation of __delitem__, called by __setitem__(Object, Object) when its argument is an integer. The argument is the equivalent int, adjusted and checked by adjustSet(int).

The default implementation deletes a slice [i:i+1] using delSlice(Indices).

Parameters
i:int

index of item to delete

Exceptions
Throwable:
from errors other than indexing
delSliceback to summary
public void delSlice(PySlice.Indices slice) throws Throwable

Inner implementation of __delitem__, called by __delitem__(Object) when its argument is a PySlice. The argument is the return from PySlice#getIndices(int), which is guaranteed to be range-compatible with the sequence length length().

In mutable types, override this to delete the given slice of the client sequence. The default implementation (for immutable types) does nothing.

Parameters
slice:PySlice.Indices

containing [start, stop, step, count] of the slice to delete

Exceptions
Throwable:
from accessing the client data
getItemback to summary
public abstract Object getItem(int i) throws Throwable

Inner implementation of __getitem__, called by __getitem__(Object) when its argument is an integer. The argument is the equivalent int, adjusted and checked by adjustGet(int).

Parameters
i:int

index of item to return

Returns:Object

the element from the client sequence

Exceptions
Throwable:
from accessing the client data

getSliceback to summary
public abstract S getSlice(PySlice.Indices slice) throws Throwable

Inner implementation of __getitem__, called by __getitem__(Object) when its argument is a PySlice. The argument is the return from PySlice#getIndices(int), which is guaranteed to be range-compatible with the sequence length length().

Parameters
slice:PySlice.Indices

containing [start, stop, step, count] of the slice to return

Returns:S

the slice from the client sequence

Exceptions
Throwable:
from errors other than indexing

getTypeback 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 PyUnicode.TYPE which is str.

Returns:PyType

the type of client sequence

getTypeNameback 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 getType().getName(), which is normally correct, but Python str likes to call itself "string", exceptionally.

Returns:String

the name of Python type being served

indexback to summary
public int index(Object v, Object start, Object stop) throws TypeError, ValueError, Throwable

Implementation of the index method of sequences. Find the index, in the given range, of an element equal to the argument. or a slice of the client sequence, after checks, by calling either getItem(int) or getSlice(Indices).

Parameters
v:Object

value to match in the client

start:Object

index of first element in range

stop:Object

index of first element not in range

Returns:int

the index at which found

Exceptions
TypeError:
from bad start and stop types
ValueError:
if v not found
Throwable:
from errors other than indexing

lengthback to summary
public abstract int length()

Redeclares org.python.core.PySequence.Of.length.

Returns the length of the client sequence from the perspective of indexing and slicing operations.

Returns:int

the length of the client sequence

Annotations
@Override

raddback to summary
pack-priv abstract Object radd(Object ov) throws OutOfMemoryError, NoConversion, Throwable

Inner implementation of __radd__ on the client sequence, called by __radd__(Object).

The implementation of this method is responsible for validating the argument. If an __radd__ is being attempted between incompatible types it should return Py#NotImplemented, or throw a NoConversion exception, which will cause __radd__ to return NotImplemented.

Parameters
ov:Object

the left operand

Returns:Object

concatenation ov+self or Py#NotImplemented

Exceptions
OutOfMemoryError:
when allocating the result fails. __radd__ will raise a Python OverflowError.
NoConversion:
(optionally) when the client does not support the type of ov.
Throwable:
from other causes in the implementation

rangeIndexErrorback to summary
protected final IndexError rangeIndexError(String kind)

Creates an IndexError with the message "getTypeName() KIND index out of range", e.g. "list assignment index out of range".

Parameters
kind:String

word to insert for KIND: "" or "assignment".

Returns:IndexError

an exception to throw

repeatback to summary
pack-priv abstract S repeat(int n) throws OutOfMemoryError, Throwable

Inner implementation of __mul__ on the client sequence, called by __mul__(Object).

Parameters
n:int

the number of repetitions

Returns:S

repetition self*n

Exceptions
OutOfMemoryError:
when allocating the result fails. __mul__ will raise a Python OverflowError.
Throwable:
from other causes in the implementation

repeatOverflowback 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.

Returns:OverflowError

an exception to throw

setItemback to summary
public void setItem(int i, Object value) throws Throwable

Inner implementation of __setitem__, called by __setitem__(Object, Object) when its argument is an integer. The argument is the equivalent int, adjusted and checked by adjustSet(int).

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.

Parameters
i:int

index of item to set

value:Object

to set at i

Exceptions
Throwable:
from accessing the client data
setSliceback to summary
public void setSlice(PySlice.Indices slice, Object value) throws Throwable

Inner implementation of __setitem__, called by __setitem__(Object, Object) when its argument is a PySlice. The argument is the return from PySlice#getIndices(int), which is guaranteed to be range-compatible with the sequence length length().

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.

Parameters
slice:PySlice.Indices

to assign in the client sequence

value:Object

to assign

Exceptions
Throwable:
from errors other than indexing
org.python.core back to summary

public Interface PySequence.Of<E>

extends Iterable<E>
Known Direct Subinterfaces
org.python.core.PySequence.OfInt
Known Direct Implementers
org.python.core.PySequence.Delegate
Type Parameters
<E>
the type of element returned by the iterators

In the implementation of sequence types, it is useful to be able to create iterables and streams from their content. This interface provides a standardised API. Several Delegate implementations in the core also provide this interface.

Method Summary

Modifier and TypeMethod and Description
public default Stream<E>

Returns:

the elements of this sequence as a Stream
asStream
()

public E

Returns:

item at index i.
get
(int
index
i
)

Get an item from the sequence at a given index i.

public int

Returns:

the length of this sequence
length
()

The length of this sequence.

public default Spliterator<E>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.
Inherited from java.lang.Iterable:
forEachiterator

Method Detail

asStreamback to summary
public default Stream<E> asStream()
Returns:Stream<E>

the elements of this sequence as a Stream

getback to summary
public E get(int i)

Get an item from the sequence at a given index i.

Parameters
i:int

index

Returns:E

item at index i.

lengthback to summary
public int length()

The length of this sequence.

Returns:int

the length of this sequence

spliteratorback to summary
public default Spliterator<E> spliterator()

Overrides default java.lang.Iterable.spliterator.

Doc from java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable. The characteristics SIZED and SUBSIZED are additionally reported.

Returns:Spliterator<E>

a Spliterator over the elements described by this Iterable.

Annotations
@Override

org.python.core back to summary

public Interface PySequence.OfInt

extends PySequence.Of<Integer>
Known Direct Implementers
org.python.core.PyUnicode.CodepointDelegate, org.python.core.PyBytes.BytesDelegate

A specialisation of PySequence.Of<Integer> where the elements may be consumed as primitive int.

Method Summary

Modifier and TypeMethod and Description
public IntStream

Returns:

a stream of primitive int
asIntStream
()

Provide a stream specialised to primitive int.

public default Stream<Integer>
public default Integer
get(int
index
i
)

Implements org.python.core.PySequence.Of.get.

Get an item from the sequence at a given index i.
public int

Returns:

item at index i.
getInt
(int
index
i
)

Get the int item from the sequence at a given index i.

public Spliterator.OfInt
spliterator()

Redeclares as abstract: org.python.core.PySequence.Of.spliterator.

Creates a Spliterator over the elements described by this Iterable.
Inherited from org.python.core.PySequence.Of:
length

Method Detail

asIntStreamback to summary
public IntStream asIntStream()

Provide a stream specialised to primitive int.

Returns:IntStream

a stream of primitive int

asStreamback to summary
public default Stream<Integer> asStream()

Overrides default org.python.core.PySequence.Of.asStream.

Implementation Note

The default implementation is the stream of values from asIntStream(), boxed to Integer. Consumers that are able, will obtain improved efficiency by preferring asIntStream() and specialising intermediate processing to int.

Returns:Stream<Integer>

Doc from org.python.core.PySequence.Of.asStream.

the elements of this sequence as a Stream

Annotations
@Override

getback to summary
public default Integer get(int i)

Implements org.python.core.PySequence.Of.get.

Doc from org.python.core.PySequence.Of.get.

Get an item from the sequence at a given index i.

Parameters
i:int

index

Returns:Integer

item at index i.

Annotations
@Override

getIntback to summary
public int getInt(int i)

Get the int item from the sequence at a given index i.

Parameters
i:int

index

Returns:int

item at index i.

spliteratorback to summary
public Spliterator.OfInt spliterator()

Redeclares as abstract: org.python.core.PySequence.Of.spliterator.

Doc from org.python.core.PySequence.Of.spliterator.

Creates a Spliterator over the elements described by this Iterable. The characteristics SIZED and SUBSIZED are additionally reported.

Returns:Spliterator.OfInt

Doc from java.lang.Iterable.spliterator.

a Spliterator over the elements described by this Iterable.

Annotations
@Override