Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.python.modules
Class itertools

    java.lang.Object
      org.python.modules.itertools

All Implemented Interfaces:
  ClassDictInit

    public class itertools

extends Object
implements ClassDictInit

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

Since:
  2.5

Field Summary
`static PyString` | `__doc__`
`static PyString` | `__doc__chain`
`static PyString` | `__doc__count`
`static PyString` | `__doc__cycle`
`static PyString` | `__doc__dropwhile`
`static PyString` | `__doc__groupby`
`static PyString` | `__doc__ifilter`
`static PyString` | `__doc__ifilterfalse`
`static PyString` | `__doc__imap`
`static PyString` | `__doc__islice`
`static PyString` | `__doc__izip`
`static PyString` | `__doc__repeat`
`static PyString` | `__doc__starmap`
`static PyString` | `__doc__takewhile`
`static PyString` | `__doc__tee`

Constructor Summary
`itertools()`

Method Summary
`static PyIterator` | `chain(PyObject[] iterables)` Creates an iterator that iterates over a chain of iterables.
`static void` | `classDictInit(PyObject dict)`
`static PyIterator` | `count()` Creates an iterator that returns consecutive integers starting at 0.
`static PyIterator` | `count(int init)` Creates an iterator that returns consecutive integers starting at `init`.
`static PyIterator` | `cycle(PyObject sequence)` Returns an iterator that iterates over an iterable, saving the values for each iteration.
`static PyIterator` | `dropwhile(PyObject predicate, PyObject iterable)` Create an iterator that drops items from the iterable while `prdicate(item)` equals true.
`static PyIterator` | `groupby(PyObject[] args, String[] kws)` Create an iterator which returns the pair (key, sub-iterator) grouped by key(value).
`static PyIterator` | `ifilter(PyObject predicate, PyObject iterable)` Creates an iterator that returns the items of the iterable for which `predicate(item)` is `true`.
`static PyIterator` | `ifilterfalse(PyObject predicate, PyObject iterable)` Creates an iterator that returns the items of the iterable for which `predicate(item)` is `false`.
`static PyIterator` | `imap(PyObject[] argstar)` Works as `__builtin__.map()` but returns an iterator instead of a list.
`static PyIterator` | `islice(PyObject iterable, PyObject stopObj)`
`static PyIterator` | `islice(PyObject iterable, PyObject start, PyObject stopObj)`
`static PyIterator` | `islice(PyObject iterable, PyObject startObj, PyObject stopObj, PyObject stepObj)` Creates an iterator that returns selected values from an iterable.
`static PyIterator` | `izip(PyObject[] argstar)` Create an iterator whose `next()` method returns a tuple where the i-th element comes from the i-th iterable argument.
`static PyIterator` | `repeat(PyObject object)` Creates an iterator that returns the same object over and over again.
`static PyIterator` | `repeat(PyObject object, int times)` Creates an iterator that returns the same object the number of times given by `times`.
`static PyIterator` | `starmap(PyObject[] starargs)` Create an iterator whose `next()` method returns the result of calling the function (first argument) with a tuple of arguments returned from the iterable (second argument).
`static PyIterator` | `takewhile(PyObject predicate, PyObject iterable)` Create an iterator that returns items from the iterable while `predicate(item)` is true.
`static PyTuple` | `tee(PyObject iterable)` Create a pair of iterators, each of which is effectively a copy of iterable.
`static PyTuple` | `tee(PyObject iterable, int n)` Create a tuple of iterators, each of which is effectively a copy of iterable.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### __doc__

    public static PyString __doc__

### __doc__count

    public static PyString __doc__count

### __doc__cycle

    public static PyString __doc__cycle

### __doc__chain

    public static PyString __doc__chain

### __doc__repeat

    public static PyString __doc__repeat

### __doc__imap

    public static PyString __doc__imap

### __doc__islice

    public static PyString __doc__islice

### __doc__ifilter

    public static PyString __doc__ifilter

### __doc__ifilterfalse

    public static PyString __doc__ifilterfalse

### __doc__izip

    public static PyString __doc__izip

### __doc__starmap

    public static PyString __doc__starmap

### __doc__dropwhile

    public static PyString __doc__dropwhile

### __doc__takewhile

    public static PyString __doc__takewhile

### __doc__groupby

    public static PyString __doc__groupby

### __doc__tee

    public static PyString __doc__tee

Constructor Detail

### itertools

    public itertools()

Method Detail

### classDictInit

    public static void classDictInit(PyObject dict)

### count

    public static PyIterator count(int init)

  Creates an iterator that returns consecutive integers starting at `init`.

### count

    public static PyIterator count()

  Creates an iterator that returns consecutive integers starting at 0.

### cycle

    public static PyIterator cycle(PyObject sequence)

  Returns an iterator that iterates over an iterable, saving the values for each iteration. When the iterable is exhausted continues to iterate over the saved values indefinitely.

### chain

    public static PyIterator chain(PyObject[] iterables)

  Creates an iterator that iterates over a chain of iterables.

### repeat

    public static PyIterator repeat(PyObject object,
                                    int times)

  Creates an iterator that returns the same object the number of times given by `times`.

### repeat

    public static PyIterator repeat(PyObject object)

  Creates an iterator that returns the same object over and over again.

### imap

    public static PyIterator imap(PyObject[] argstar)

  Works as `__builtin__.map()` but returns an iterator instead of a list. (Code in this method is based on __builtin__.map()).

### islice

    public static PyIterator islice(PyObject iterable,
                                    PyObject startObj,
                                    PyObject stopObj,
                                    PyObject stepObj)

  Creates an iterator that returns selected values from an iterable.

  Parameters:
    `startObj` - the index of where in the iterable to start returning values
    `stopObj` - the index of where in the iterable to stop returning values
    `stepObj` - the number of steps to take beween each call to `next()`

### islice

    public static PyIterator islice(PyObject iterable,
                                    PyObject stopObj)

  See Also:
    `startObj defaults to 0 and stepObj to 1`

### islice

    public static PyIterator islice(PyObject iterable,
                                    PyObject start,
                                    PyObject stopObj)

  See Also:
    `stepObj defaults to 1`

### ifilter

    public static PyIterator ifilter(PyObject predicate,
                                     PyObject iterable)

  Creates an iterator that returns the items of the iterable for which `predicate(item)` is `true`. If `predicate` is null (None) return the items that are true.

### ifilterfalse

    public static PyIterator ifilterfalse(PyObject predicate,
                                          PyObject iterable)

  Creates an iterator that returns the items of the iterable for which `predicate(item)` is `false`. If `predicate` is null (None) return the items that are false.

### izip

    public static PyIterator izip(PyObject[] argstar)

  Create an iterator whose `next()` method returns a tuple where the i-th element comes from the i-th iterable argument. Continues until the shortest iterable is exhausted. (Code in this method is based on __builtin__.zip()).

### starmap

    public static PyIterator starmap(PyObject[] starargs)

  Create an iterator whose `next()` method returns the result of calling the function (first argument) with a tuple of arguments returned from the iterable (second argument).

  Parameters:
    `starargs` - [0] = callable function, [1] = iterable with argument tuples

### dropwhile

    public static PyIterator dropwhile(PyObject predicate,
                                       PyObject iterable)

  Create an iterator that drops items from the iterable while `prdicate(item)` equals true. After which every remaining item of the iterable is returned.

### takewhile

    public static PyIterator takewhile(PyObject predicate,
                                       PyObject iterable)

  Create an iterator that returns items from the iterable while `predicate(item)` is true. After which iteration is stopped.

### groupby

    public static PyIterator groupby(PyObject[] args,
                                     String[] kws)

  Create an iterator which returns the pair (key, sub-iterator) grouped by key(value).

### tee

    public static PyTuple tee(PyObject iterable,
                              int n)

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

### tee

    public static PyTuple tee(PyObject iterable)

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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Jython homepage