コード例 #1
0
 @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___rmul___doc)
 final synchronized PyObject list___rmul__(PyObject o) {
   if (!o.isIndex()) {
     return null;
   }
   return repeat(o.asIndex(Py.OverflowError));
 }
コード例 #2
0
  @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___imul___doc)
  final synchronized PyObject list___imul__(PyObject o) {
    if (!o.isIndex()) {
      return null;
    }
    int count = o.asIndex(Py.OverflowError);

    int size = size();
    if (size == 0 || count == 1) {
      return this;
    }

    if (count < 1) {
      clear();
      return this;
    }

    if (size > Integer.MAX_VALUE / count) {
      throw Py.MemoryError("");
    }

    int newSize = size * count;
    if (list instanceof ArrayList) {
      ((ArrayList) list).ensureCapacity(newSize);
    }
    List<PyObject> oldList = new ArrayList<PyObject>(list);
    for (int i = 1; i < count; i++) {
      list.addAll(oldList);
    }
    gListAllocatedStatus = __len__(); // now omit?
    return this;
  }