/** rb_ary_make_shared * */ private RubyArray makeShared() { return makeShared(begin, realLength, getMetaClass()); }
/** rb_ary_make_shared * */ private RubyArray makeShared() { return makeShared(begin, realLength, getMetaClass()); }
/** rb_ary_make_shared * */ private RubyArray makeShared() { // TODO: (CON) Some calls to makeShared could create packed array almost as efficiently unpack(); return makeShared(begin, realLength, getMetaClass()); }
/** ary_shared_first * */ private RubyArray makeSharedFirst(ThreadContext context, IRubyObject num, boolean last, RubyClass klass) { int n = RubyNumeric.num2int(num); if (n > realLength) { n = realLength; } else if (n < 0) { throw context.runtime.newArgumentError("negative array size"); } return makeShared(last ? begin + realLength - n : begin, n, klass); }
/** rb_ary_make_shared * */ private RubyArray makeShared() { // TODO: (CON) Some calls to makeShared could create packed array almost as efficiently unpack(); return makeShared(begin, realLength, getMetaClass()); }
/** ary_shared_first * */ private RubyArray makeSharedFirst(ThreadContext context, IRubyObject num, boolean last, RubyClass klass) { int n = RubyNumeric.num2int(num); if (n > realLength) { n = realLength; } else if (n < 0) { throw context.runtime.newArgumentError("negative array size"); } return makeShared(last ? begin + realLength - n : begin, n, klass); }
/** ary_shared_first * */ private RubyArray makeSharedFirst(ThreadContext context, IRubyObject num, boolean last, RubyClass klass) { int n = RubyNumeric.num2int(num); if (n > realLength) { n = realLength; } else if (n < 0) { throw context.runtime.newArgumentError("negative array size"); } return makeShared(last ? begin + realLength - n : begin, n, klass); }
/** ary_shared_first * */ private RubyArray makeSharedFirst(ThreadContext context, IRubyObject num, boolean last, RubyClass klass) { int n = RubyNumeric.num2int(num); if (n > realLength) { n = realLength; } else if (n < 0) { throw context.runtime.newArgumentError("negative array size"); } return makeShared(last ? begin + realLength - n : begin, n, klass); }
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 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)); }
@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 = "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 = "flatten", compat = RUBY1_9) public IRubyObject flatten19(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; int level = RubyNumeric.num2int(arg); if (level == 0) return makeShared(); RubyArray result = new RubyArray(runtime, getMetaClass(), realLength); flatten(context, level, result); result.infectBy(this); return result; }
@JRubyMethod(name = "flatten", compat = RUBY1_9) public IRubyObject flatten19(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; int level = RubyNumeric.num2int(arg); if (level == 0) return makeShared(); RubyArray result = new RubyArray(runtime, getMetaClass(), realLength); flatten(context, level, result); result.infectBy(this); return result; }
/** rb_ary_last * */ @JRubyMethod(name = "last") public IRubyObject last(IRubyObject arg0) { long n = RubyNumeric.num2long(arg0); if (n > realLength) { n = realLength; } else if (n < 0) { throw getRuntime().newArgumentError("negative array size (or size too big)"); } return makeShared(begin + realLength - (int) n, (int) n, getRuntime().getArray()); }
/** rb_ary_first * */ @JRubyMethod(name = "first") public IRubyObject first(IRubyObject arg0) { long n = RubyNumeric.num2long(arg0); if (n > realLength) { n = realLength; } else if (n < 0) { throw getRuntime().newArgumentError("negative array size (or size too big)"); } return makeShared(begin, (int) n, getRuntime().getArray()); }
/** rb_ary_last * */ @JRubyMethod(name = "last") public IRubyObject last(IRubyObject arg0) { long n = RubyNumeric.num2long(arg0); if (n > realLength) { n = realLength; } else if (n < 0) { throw getRuntime().newArgumentError("negative array size (or size too big)"); } return makeShared(begin + realLength - (int) n, (int) n, getRuntime().getArray()); }
/** rb_ary_subseq * */ public IRubyObject subseqLight(long beg, long len) { 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, getMetaClass(), IRubyObject.NULL_ARRAY, false); return makeShared(begin + (int) beg, (int) len, new RubyArray(runtime, getMetaClass(), false)); }
/** rb_ary_subseq * */ public IRubyObject subseqLight(long beg, long len) { 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, getMetaClass(), IRubyObject.NULL_ARRAY, false); return makeShared(begin + (int) beg, (int) len, new RubyArray(runtime, getMetaClass(), false)); }
/** rb_ary_first * */ @JRubyMethod(name = "first") public IRubyObject first(IRubyObject arg0) { long n = RubyNumeric.num2long(arg0); if (n > realLength) { n = realLength; } else if (n < 0) { throw getRuntime().newArgumentError("negative array size (or size too big)"); } return makeShared(begin, (int) n, getRuntime().getArray()); }