public static RubyArray newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin, int length) { assert begin >= 0 : "begin must be >= 0"; assert length >= 0 : "length must be >= 0"; return new RubyArray(runtime, args, begin, length); }
public static RubyArray newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin) { assert begin >= 0 : "begin must be >= 0"; assert begin <= args.length : "begin must be <= length"; return new RubyArray(runtime, args, begin, args.length - begin); }
public static RubyArray newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin) { assert begin >= 0 : "begin must be >= 0"; assert begin <= args.length : "begin must be <= length"; return new RubyArray(runtime, args, begin, args.length - begin); }
public static RubyArray newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin, int length) { assert begin >= 0 : "begin must be >= 0"; assert length >= 0 : "length must be >= 0"; return new RubyArray(runtime, args, begin, length); }
public static RubyArray newArrayNoCopyLight(Ruby runtime, IRubyObject[] args) { RubyArray arr = new RubyArray(runtime, false); arr.values = args; arr.realLength = args.length; return arr; }
public static final RubyArray newArray(final Ruby runtime, final int len) { IRubyObject[] values = len == 0 ? IRubyObject.NULL_ARRAY : new IRubyObject[len]; Helpers.fillNil(values, 0, len, runtime); return new RubyArray(runtime, values, 0, 0); }
public static final RubyArray newArrayLight(final Ruby runtime, final int len) { IRubyObject[] values = len == 0 ? IRubyObject.NULL_ARRAY : new IRubyObject[len]; Helpers.fillNil(values, 0, len, runtime); return new RubyArray(runtime, values, 0, 0, false); }
public IRubyObject subseq(RubyClass metaClass, long beg, long len, boolean light) { Ruby runtime = getRuntime(); if (beg > realLength || beg < 0 || len < 0) return runtime.getNil(); if (beg + len > realLength) { len = realLength - beg; if (len < 0) len = 0; } if (len == 0) return new RubyArray(runtime, metaClass, IRubyObject.NULL_ARRAY, !light); return makeShared(begin + (int) beg, (int) len, new RubyArray(runtime, metaClass, !light)); }
public static RubyArray newArray(Ruby runtime, List<? extends IRubyObject> list) { if (list.isEmpty()) { return newEmptyArray(runtime); } return isPackedArray(list) ? packedArray(runtime, list) : new RubyArray(runtime, list.toArray(IRubyObject.NULL_ARRAY)); }
public static RubyArray newArray(Ruby runtime, Collection<? extends IRubyObject> collection) { if (collection.isEmpty()) { return newEmptyArray(runtime); } final IRubyObject[] arr = collection.toArray(IRubyObject.NULL_ARRAY); return isPackedArray(collection) ? packedArray(runtime, arr) : new RubyArray(runtime, arr); }
/** rb_assoc_new * */ public static RubyArray newArray(Ruby runtime, IRubyObject car, IRubyObject cdr) { return USE_PACKED_ARRAYS ? new RubyArrayTwoObject(runtime, car, cdr) : new RubyArray(runtime, arrayOf(car, cdr)); }
/** rb_assoc_new * */ public static RubyArray newArray(Ruby runtime, IRubyObject car, IRubyObject cdr) { return USE_PACKED_ARRAYS ? new RubyArrayTwoObject(runtime, car, cdr) : new RubyArray(runtime, arrayOf(car, cdr)); }
public static RubyArray newArray(Ruby runtime, List<? extends IRubyObject> list) { if (list.isEmpty()) { return newEmptyArray(runtime); } return isPackedArray(list) ? packedArray(runtime, list) : new RubyArray(runtime, list.toArray(IRubyObject.NULL_ARRAY)); }
public static RubyArray newArray(Ruby runtime, Collection<? extends IRubyObject> collection) { if (collection.isEmpty()) { return newEmptyArray(runtime); } final IRubyObject[] arr = collection.toArray(IRubyObject.NULL_ARRAY); return isPackedArray(collection) ? packedArray(runtime, arr) : new RubyArray(runtime, arr); }
/** * Overridden dup for fast-path logic. * * @return A new RubyArray sharing the original backing store. */ public IRubyObject dup() { if (metaClass.getClassIndex() != ClassIndex.ARRAY) return super.dup(); RubyArray dup = new RubyArray(metaClass.getClassRuntime(), values, begin, realLength); dup.isShared = isShared = true; dup.flags |= flags & TAINTED_F; // from DUP_SETUP return dup; }
/** * Overridden dup for fast-path logic. * * @return A new RubyArray sharing the original backing store. */ public IRubyObject dup() { if (metaClass.getClassIndex() != ClassIndex.ARRAY) return super.dup(); RubyArray dup = new RubyArray(metaClass.getClassRuntime(), values, begin, realLength); dup.isShared = isShared = true; dup.flags |= flags & TAINTED_F; // from DUP_SETUP return dup; }
@JRubyMethod(name = "flatten") public IRubyObject flatten(ThreadContext context) { Ruby runtime = context.runtime; RubyArray result = new RubyArray(runtime, getType(), realLength); flatten(context, -1, result); result.infectBy(this); return result; }
/** rb_ary_new4, rb_ary_new3 * */ public static RubyArray newArray(Ruby runtime, IRubyObject[] args) { final int size = args.length; if (size == 0) { return newEmptyArray(runtime); } return isPackedArray(size) ? packedArray(runtime, args) : new RubyArray(runtime, args.clone()); }
@JRubyMethod(name = "flatten") public IRubyObject flatten(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; int level = RubyNumeric.num2int(arg); if (level == 0) return makeShared(); RubyArray result = new RubyArray(runtime, getType(), realLength); flatten(context, level, result); result.infectBy(this); return result; }
@JRubyMethod(name = "uniq") public IRubyObject uniq19(ThreadContext context, Block block) { if (!block.isGiven()) return uniq(context); RubyHash hash = makeHash(context, block); RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size()); hash.visitAll(context, RubyHash.StoreValueVisitor, result); return result; }