public boolean includes(ThreadContext context, IRubyObject item) { int myBegin = this.begin; int end = myBegin + realLength; IRubyObject[] values = this.values; final Ruby runtime = context.runtime; for (int i = myBegin; i < end; i++) { final IRubyObject value = safeArrayRef(runtime, values, i); if (equalInternal(context, value, item)) return true; } return false; }
public boolean includes(ThreadContext context, IRubyObject item) { int myBegin = this.begin; int end = myBegin + realLength; IRubyObject[] values = this.values; for (int i = myBegin; i < end; i++) { final IRubyObject value = safeArrayRef(values, i); if (equalInternal(context, value, item)) return true; } return false; }
public boolean includes(ThreadContext context, IRubyObject item) { int myBegin = this.begin; int end = myBegin + realLength; IRubyObject[] values = this.values; final Ruby runtime = context.runtime; for (int i = myBegin; i < end; i++) { final IRubyObject value = safeArrayRef(runtime, values, i); if (equalInternal(context, value, item)) return true; } return false; }
public boolean includes(ThreadContext context, IRubyObject item) { int myBegin = this.begin; int end = myBegin + realLength; IRubyObject[] values = this.values; for (int i = myBegin; i < end; i++) { final IRubyObject value = safeArrayRef(values, i); if (equalInternal(context, value, item)) return true; } return false; }
/** rb_ary_index * */ public IRubyObject index(ThreadContext context, IRubyObject obj) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { if (equalInternal(context, eltOk(i), obj)) return runtime.newFixnum(i); } return runtime.getNil(); }
/** rb_ary_index * */ public IRubyObject index(ThreadContext context, IRubyObject obj) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { if (equalInternal(context, eltOk(i), obj)) return runtime.newFixnum(i); } return runtime.getNil(); }
/** rb_ary_index * */ public IRubyObject index(ThreadContext context, IRubyObject obj) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { if (equalInternal(context, eltOk(i), obj)) return runtime.newFixnum(i); } return runtime.getNil(); }
/** rb_ary_index * */ public IRubyObject index(ThreadContext context, IRubyObject obj) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { if (equalInternal(context, eltOk(i), obj)) return runtime.newFixnum(i); } return runtime.getNil(); }
/** rb_ary_rindex * */ public IRubyObject rindex(ThreadContext context, IRubyObject obj) { Ruby runtime = context.runtime; int i = realLength; while (i-- > 0) { if (i > realLength) { i = realLength; continue; } if (equalInternal(context, eltOk(i), obj)) return runtime.newFixnum(i); } return runtime.getNil(); }
/** rb_ary_rindex * */ public IRubyObject rindex(ThreadContext context, IRubyObject obj) { Ruby runtime = context.runtime; int i = realLength; while (i-- > 0) { if (i > realLength) { i = realLength; continue; } if (equalInternal(context, eltOk(i), obj)) return runtime.newFixnum(i); } return runtime.getNil(); }
/** rb_ary_assoc * */ @JRubyMethod(name = "assoc", required = 1) public IRubyObject assoc(ThreadContext context, IRubyObject key) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { IRubyObject v = eltOk(i); if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 0 && equalInternal(context, arr.elt(0), key)) return arr; } } return runtime.getNil(); }
/** rb_ary_assoc * */ @JRubyMethod(name = "assoc", required = 1) public IRubyObject assoc(ThreadContext context, IRubyObject key) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { IRubyObject v = eltOk(i); if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 0 && equalInternal(context, arr.elt(0), key)) return arr; } } return runtime.getNil(); }
/** rb_ary_rassoc * */ @JRubyMethod(name = "rassoc", required = 1) public IRubyObject rassoc(ThreadContext context, IRubyObject value) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { IRubyObject v = eltOk(i); if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 1 && equalInternal(context, arr.eltOk(1), value)) return arr; } } return runtime.getNil(); }
public boolean remove(Object element) { Ruby runtime = getRuntime(); ThreadContext context = runtime.getCurrentContext(); IRubyObject item = JavaUtil.convertJavaToUsableRubyObject(runtime, element); boolean listchanged = false; for (int i1 = 0; i1 < realLength; i1++) { IRubyObject e = values[begin + i1]; if (equalInternal(context, e, item)) { delete_at(i1); listchanged = true; break; } } return listchanged; }
/** rb_ary_assoc * */ @JRubyMethod(name = "assoc", required = 1) public IRubyObject assoc(ThreadContext context, IRubyObject key) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { IRubyObject v = eltOk(i); if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 0 && equalInternal(context, arr.elt(0), key)) return arr; } } return runtime.getNil(); }
/** rb_ary_rassoc * */ @JRubyMethod(name = "rassoc", required = 1) public IRubyObject rassoc(ThreadContext context, IRubyObject value) { Ruby runtime = context.runtime; for (int i = 0; i < realLength; i++) { IRubyObject v = eltOk(i); if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 1 && equalInternal(context, arr.eltOk(1), value)) return arr; } } return runtime.getNil(); }
@JRubyMethod(name = "count") public IRubyObject count(ThreadContext context, IRubyObject obj, Block block) { if (block.isGiven()) context.runtime.getWarnings().warn(ID.BLOCK_UNUSED, "given block not used"); int n = 0; for (int i = 0; i < realLength; i++) { if (equalInternal(context, elt(i), obj)) n++; } return RubyFixnum.newFixnum(context.runtime, n); }
@JRubyMethod(name = "count") public IRubyObject count(ThreadContext context, IRubyObject obj, Block block) { if (block.isGiven()) context.runtime.getWarnings().warn(ID.BLOCK_UNUSED, "given block not used"); int n = 0; for (int i = 0; i < realLength; i++) { if (equalInternal(context, elt(i), obj)) n++; } return RubyFixnum.newFixnum(context.runtime, n); }
@JRubyMethod(name = "count") public IRubyObject count(ThreadContext context, IRubyObject obj, Block block) { if (block.isGiven()) context.runtime.getWarnings().warn(ID.BLOCK_UNUSED, "given block not used"); int n = 0; for (int i = 0; i < realLength; i++) { if (equalInternal(context, elt(i), obj)) n++; } return RubyFixnum.newFixnum(context.runtime, n); }
@JRubyMethod(name = "count") public IRubyObject count(ThreadContext context, IRubyObject obj, Block block) { if (block.isGiven()) context.runtime.getWarnings().warn(ID.BLOCK_UNUSED, "given block not used"); int n = 0; for (int i = 0; i < realLength; i++) { if (equalInternal(context, elt(i), obj)) n++; } return RubyFixnum.newFixnum(context.runtime, n); }