Top Description Inners Fields Constructors Methods
org.python.modules.itertools

public Class itertools

extends Object
implements ClassDictInit
Class Inheritance
All Implemented Interfaces
org.python.core.ClassDictInit
Imports
org.python.core.ClassDictInit, .Py, .PyException, .PyIterator, .PyNone, .PyObject, .PyString, .PyTuple, .Visitproc

Functional tools for creating and using iterators. Java implementation of the CPython module itertools.
Since
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
itertools.FilterIterator

Iterator base class for iterators returned by ifilter and ifilterfalse.

pack-priv abstract static class
itertools.ItertoolsIterator

Iterator base class used by most methods.

pack-priv static class
itertools.WhileIterator

Iterator base class used by dropwhile() and takewhile.

Field Summary

Modifier and TypeField and Description
public static final PyString
public static PyString

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
pack-priv static PyTuple
makeIndexedTuple(PyTuple pool, int[] indices)

pack-priv static PyTuple
makeIndexedTuple(PyTuple pool, int[] indices, int end)

pack-priv static int
py2int(PyObject obj, int defaultValue, String msg)

public static PyTuple
tee(PyObject iterable, final int n)

Create a tuple of iterators, each of which is effectively a copy of iterable.

public static PyTuple
tee(PyObject iterable)

Create a pair of iterators, each of which is effectively a copy of iterable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__doc__back to summary
public static final PyString __doc__
__doc__teeback to summary
public static PyString __doc__tee

Constructor Detail

itertoolsback to summary
public itertools()

Method Detail

classDictInitback to summary
public static void classDictInit(PyObject dict)
makeIndexedTupleback to summary
pack-priv static PyTuple makeIndexedTuple(PyTuple pool, int[] indices)
makeIndexedTupleback to summary
pack-priv static PyTuple makeIndexedTuple(PyTuple pool, int[] indices, int end)
py2intback to summary
pack-priv static int py2int(PyObject obj, int defaultValue, String msg)
teeback to summary
public static PyTuple tee(PyObject iterable, final int n)

Create a tuple of iterators, each of which is effectively a copy of iterable.

teeback to summary
public static PyTuple tee(PyObject iterable)

Create a pair of iterators, each of which is effectively a copy of iterable.

org.python.modules.itertools back to summary

pack-priv Class itertools.FilterIterator

extends ItertoolsIterator
Class Inheritance

Iterator base class for iterators returned by ifilter and ifilterfalse.

Field Summary

Modifier and TypeField and Description
private boolean
private PyObject
private PyObject

Constructor Summary

AccessConstructor and Description
pack-priv
FilterIterator(PyObject predicate, PyObject iterable, boolean filterTrue)

Method Summary

Modifier and TypeMethod and Description
public PyObject
__iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Return the next element of the sequence that this is an iterator for.

public boolean
public int
traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyIterator.traverse.

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.modules.itertools.itertools.ItertoolsIterator:
nextElement

Field Detail

filterTrueback to summary
private boolean filterTrue
iteratorback to summary
private PyObject iterator
predicateback to summary
private PyObject predicate

Constructor Detail

FilterIteratorback to summary
pack-priv FilterIterator(PyObject predicate, PyObject iterable, boolean filterTrue)

Method Detail

__iternext__back to summary
public PyObject __iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Doc from org.python.core.PyObject.__iternext__.

Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.

refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Overrides org.python.core.PyIterator.refersDirectlyTo.

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
traverseback to summary
public int traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyIterator.traverse.

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
org.python.modules.itertools back to summary

pack-priv abstract Class itertools.ItertoolsIterator

extends PyIterator
Class Inheritance
Known Direct Subclasses
org.python.modules.itertools.itertools.FilterIterator, org.python.modules.itertools.itertools.WhileIterator

Iterator base class used by most methods.

Field Summary

Inherited from org.python.core.PyIterator:
__doc__nextstopException

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected PyObject
nextElement(PyObject pyIter)

Returns the next element from an iterator.

Inherited from org.python.core.PyIterator:
__iter____iternext____tojava__doNextiteratornextrefersDirectlyTotraverse

Constructor Detail

ItertoolsIteratorback to summary
pack-priv ItertoolsIterator()

Method Detail

nextElementback to summary
protected PyObject nextElement(PyObject pyIter)

Returns the next element from an iterator. If it raises/throws StopIteration just store the Exception and return null according to PyIterator practice.

org.python.modules.itertools back to summary

pack-priv Class itertools.WhileIterator

extends ItertoolsIterator
Class Inheritance

Iterator base class used by dropwhile() and takewhile.

Field Summary

Modifier and TypeField and Description
private boolean
private PyObject
private PyObject
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
WhileIterator(PyObject predicate, PyObject iterable, boolean drop)

Method Summary

Modifier and TypeMethod and Description
public PyObject
__iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Return the next element of the sequence that this is an iterator for.

public boolean
public int
traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyIterator.traverse.

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.modules.itertools.itertools.ItertoolsIterator:
nextElement

Field Detail

dropback to summary
private boolean drop
iteratorback to summary
private PyObject iterator
predicateback to summary
private PyObject predicate
predicateSatisfiedback to summary
private boolean predicateSatisfied

Constructor Detail

WhileIteratorback to summary
pack-priv WhileIterator(PyObject predicate, PyObject iterable, boolean drop)

Method Detail

__iternext__back to summary
public PyObject __iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Doc from org.python.core.PyObject.__iternext__.

Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.

refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Overrides org.python.core.PyIterator.refersDirectlyTo.

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
traverseback to summary
public int traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyIterator.traverse.

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