@Override public PyObject __iternext__() { if (firstthru) { for (PyTuple pool : pools) { if (pool.__len__() == 0) { return null; } } firstthru = false; return makeTuple(); } for (int i = num_pools - 1; i >= 0; i--) { indices[i]++; if (indices[i] == pools[i].__len__()) { indices[i] = 0; } else { return makeTuple(); } } return null; }
private void combinationsWithReplacement___init__(PyObject iterable, final int r) { final PyTuple pool = PyTuple.fromIterable(iterable); final int n = pool.__len__(); final int indices[] = new int[r]; for (int i = 0; i < r; i++) { indices[i] = 0; } iter = new itertools.ItertoolsIterator() { boolean firstthru = true; @Override public PyObject __iternext__() { if (firstthru) { firstthru = false; if (n == 0 && r > 0) { return null; } return itertools.makeIndexedTuple(pool, indices); } int i; for (i = r - 1 ; i >= 0 && indices[i] == n - 1; i--); if (i < 0) return null; indices[i]++; for (int j = i + 1; j < r; j++) { indices[j] = indices[j-1]; } return itertools.makeIndexedTuple(pool, indices); } }; }
private void permutations___init__(final PyObject iterable, final int r) { final PyTuple pool = PyTuple.fromIterable(iterable); final int n = pool.__len__(); final int indices[] = new int[n]; for (int i = 0; i < n; i++) {
private String[] read_strings(int depth) { PyTuple t = (PyTuple) read_object_notnull(depth); String some_strings[] = new String[t.__len__()]; int i = 0; for (PyObject item : t.asIterable()) { some_strings[i++] = item.toString().intern(); } return some_strings; }
private void combinations___init__(PyObject iterable, final int r) { if (r < 0) throw Py.ValueError("r must be non-negative"); final PyTuple pool = PyTuple.fromIterable(iterable); final int n = pool.__len__(); final int indices[] = new int[r]; for (int i = 0; i < r; i++) { indices[i] = i; } iter = new itertools.ItertoolsIterator() { boolean firstthru = true; @Override public PyObject __iternext__() { if (r > n) { return null; } if (firstthru) { firstthru = false; return itertools.makeIndexedTuple(pool, indices); } int i; for (i = r-1; i >= 0 && indices[i] == i+n-r ; i--); if (i < 0) return null; indices[i]++; for (int j = i+1; j < r; j++) { indices[j] = indices[j-1] + 1; } return itertools.makeIndexedTuple(pool, indices); } }; }
public static PyString asctime(PyObject obj) { PyTuple tup; if (obj instanceof PyTuple) { tup = (PyTuple)obj; } else { tup = PyTuple.fromIterable(obj); } int len = tup.__len__(); if (len != 9) { throw Py.TypeError( String.format("argument must be sequence of length 9, not %d", len)); } StringBuilder buf = new StringBuilder(25); buf.append(enshortdays[item(tup, 6)]).append(' '); buf.append(enshortmonths[item(tup, 1)]).append(' '); int dayOfMonth = item(tup, 2); if(dayOfMonth < 10){ buf.append(' '); } buf.append(dayOfMonth).append(' '); buf.append(_twodigit(item(tup, 3))).append(':'); buf.append(_twodigit(item(tup, 4))).append(':'); buf.append(_twodigit(item(tup, 5))).append(' '); return new PyString(buf.append(item(tup, 0)).toString()); }
public int __len__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__len__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); return res.asInt(); } return super.__len__(); }
if (o instanceof PyTuple) { PyTuple tuple = (PyTuple) o; int len = tuple.__len__(); if ((globals == null || globals.equals(None)) && (locals == null || locals.equals(None))
write_byte(TYPE_TUPLE); PyTuple t = (PyTuple) v; int n = t.__len__(); write_int(n); for (int i = 0; i < n; i++) {