public int hashCode() { int hash = 0; // for (RubyValue v : array_) { for (Iterator iter = array_.iterator(); iter.hasNext(); ) { RubyValue v = (RubyValue) iter.next(); hash += v.hashCode(); } return hash; }
public RubyArray copy() { RubyArray resultArray = new RubyArray(array_.size()); // for (RubyValue v : array_) { for (Iterator iter = array_.iterator(); iter.hasNext(); ) { RubyValue v = (RubyValue) iter.next(); resultArray.add(v); } return resultArray; }
// @RubyLevelMethod(name="each") public RubyValue each(RubyBlock block) { // for (RubyValue item : array_) { for (Iterator iter = array_.iterator(); iter.hasNext(); ) { RubyValue item = (RubyValue) iter.next(); RubyValue v = block.invoke(this, item); if (block.breakedOrReturned()) { return v; } } return this; }
// @RubyLevelMethod(name="include?") public RubyValue include(RubyValue v) { // for (RubyValue value : array_) { for (Iterator iter = array_.iterator(); iter.hasNext(); ) { RubyValue value = (RubyValue) iter.next(); if (RubyAPI.testEqual(value, v)) { return RubyConstant.QTRUE; } } return RubyConstant.QFALSE; }
// @RubyLevelMethod(name="&") public RubyArray and(RubyValue value) { RubyArray other = value.toAry(); RubyArray a = new RubyArray(); // for (RubyValue v : array_) { for (Iterator iter = array_.iterator(); iter.hasNext(); ) { RubyValue v = (RubyValue) iter.next(); if (other.include(v) == RubyConstant.QTRUE && a.include(v) == RubyConstant.QFALSE) { a.add(v); } } return a; }
public Iterator /*<RubyValue>*/ iterator() { return array_.iterator(); }