public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof KVComparator) { return cmp.equals(((KVComparator) o).cmp); } return false; } }
public boolean equals(Object other) { if (!(other instanceof _Callback)) return false; _Callback that = (_Callback) other; return callback.equals(that.callback); } }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof KVComparator) { return cmp.equals(((KVComparator) o).cmp); } return false; } }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof PyObjectComparator) { return cmp.equals(((PyObjectComparator) o).cmp); } return false; } }
final boolean object___contains__(PyObject o) { for (PyObject item : asIterable()) { if (o.equals(item)) { return true; } } return false; }
@ExposedMethod(doc = BuiltinDocs.tuple_count_doc) final int tuple_count(PyObject value) { int count = 0; for (PyObject item : array) { if (item.equals(value)) { count++; } } return count; }
@ExposedMethod(doc = BuiltinDocs.list_count_doc) final synchronized int list_count(PyObject o) { int count = 0; for (PyObject item : list) { if (item.equals(o)) { count++; } } return count; }
public boolean equals(Object ob) { if (ob instanceof WeakReferenceGC) { return ((WeakReferenceGC) ob).get().equals(get()) && ((WeakReferenceGC) ob).hashCode() == hashCode(); } else if (ob instanceof WeakrefGCCompareDummy) { return ((WeakrefGCCompareDummy) ob).compare != null && ((WeakrefGCCompareDummy) ob).compare.equals(get()); } else { return false; } } }
final int tuple_index(PyObject value, int start, int stop) { int validStart = boundToSequence(start); int validStop = boundToSequence(stop); for (int i = validStart; i < validStop; i++) { if (array[i].equals(value)) { return i; } } throw Py.ValueError("tuple.index(x): x not in list"); }
/** * Return the smallest <em>i</em> such that <em>i</em> is the index of the first occurrence of * <code>value</code> in the array. * * @param value value to find the index of * @return index of the first occurrence of <code>value</code> */ private int indexInternal(PyObject value) { // note: cpython does not raise type errors based on item type int len = delegate.getSize(); if ("u".equals(typecode)) { int codepoint = getCodePointOrInt(value); for (int i = 0; i < len; i++) { if (codepoint == Array.getInt(data, i)) { return i; } } } else { for (int i = 0; i < len; i++) { if (value.equals(Py.java2py(Array.get(data, i)))) { return i; } } } return -1; }
private int _index(PyObject o, String message, int start, int stop) { // Follow Python 2.3+ behavior int validStop = boundToSequence(stop); int validStart = boundToSequence(start); int i = validStart; if (validStart <= validStop) { try { for (PyObject item : list.subList(validStart, validStop)) { if (item.equals(o)) { return i; } i++; } } catch (ConcurrentModificationException ex) { throw Py.ValueError(message); } } throw Py.ValueError(message); }
/** * Count the number of deque elements equal to x. */ @ExposedMethod public synchronized final PyObject deque_count(PyObject x) { int n = size; int count = 0; Node tmp = header.right; long startState = state; for (int i = 0; i < n; i++) { if (tmp.data.equals(x)) { count++; } if (startState != state) { throw Py.RuntimeError("deque mutated during count()."); } tmp = tmp.right; } return Py.newInteger(count); }
@ExposedMethod public final int array_count(PyObject value) { // note: cpython does not raise type errors based on item type; int iCount = 0; int len = delegate.getSize(); if ("u".equals(typecode)) { int codepoint = getCodePointOrInt(value); for (int i = 0; i < len; i++) { if (codepoint == Array.getInt(data, i)) { iCount++; } } } else { for (int i = 0; i < len; i++) { if (value.equals(Py.java2py(Array.get(data, i)))) { iCount++; } } } return iCount; }
protected static int cmp(PyObject o1, int ol1, PyObject o2, int ol2) { if (ol1 < 0) { ol1 = o1.__len__(); } if (ol2 < 0) { ol2 = o2.__len__(); } for (int i = 0 ; i < ol1 && i < ol2; i++) { if (!o1.__getitem__(i).equals(o2.__getitem__(i))) { return i; } } if (ol1 == ol2) { return -2; } return (ol1 < ol2) ? -1 : -3; }
/** * Removed the first occurrence of value. If not found, raises a * ValueError. */ @ExposedMethod public synchronized final PyObject deque_remove(PyObject value) { int n = size; Node tmp = header.right; boolean match = false; long startState = state; for (int i = 0; i < n; i++) { if (tmp.data.equals(value)) { match = true; } if (startState != state) { throw Py.IndexError("deque mutated during remove()."); } if (match) { return removeNode(tmp); } tmp = tmp.right; } throw Py.ValueError("deque.remove(x): x not in deque"); }
public PyObject __iternext__() { while (currentKey.equals(targetKey)) { currentValue = nextElement(iterator); if (currentValue == null) { return null; } if (keyfunc == Py.None) { currentKey = currentValue; } else { currentKey = keyfunc.__call__(currentValue); } } targetKey = currentKey; return new PyTuple(currentKey, new GroupByIterator()); }
/** * Compare the specified object/length pairs. * * @return value >= 0 is the index where the sequences differs. -1: reached the end of o1 * without a difference -2: reached the end of both seqeunces without a difference -3: * reached the end of o2 without a difference */ protected static int cmp(PyObject o1, int ol1, PyObject o2, int ol2) { if (ol1 < 0) { ol1 = o1.__len__(); } if (ol2 < 0) { ol2 = o2.__len__(); } for (int i = 0; i < ol1 && i < ol2; i++) { if (!o1.__getitem__(i).equals(o2.__getitem__(i))) { return i; } } if (ol1 == ol2) { return -2; } return ol1 < ol2 ? -1 : -3; }
final private static PyObject whichmodule(PyObject cls, PyObject clsname) { PyObject name = classmap.get(cls); if (name != null) return name; name = new PyString("__main__"); // For use with JPython1.0.x //PyObject modules = sys.modules; // For use with JPython1.1.x //PyObject modules = Py.getSystemState().modules; PyObject sys = imp.importName("sys", true); PyObject modules = sys.__findattr__("modules"); PyObject keylist = modules.invoke("keys"); int len = keylist.__len__(); for (int i = 0; i < len; i++) { PyObject key = keylist.__finditem__(i); PyObject value = modules.__finditem__(key); if (!key.equals("__main__") && value.__findattr__(clsname.toString().intern()) == cls) { name = key; break; } } classmap.put(cls, name); //System.out.println(name); return name; }
private void module___init__(PyObject name, PyObject doc) { ensureDict(); __dict__.__setitem__("__name__", name); __dict__.__setitem__("__doc__", doc); if (name.equals(new PyString("__main__"))) { __dict__.__setitem__("__builtins__", Py.getSystemState().modules.__finditem__("__builtin__")); __dict__.__setitem__("__package__", Py.None); } }