Beispiel #1
0
 private void sort() {
   Collections.sort(
       array_,
       new Comparator /*<RubyValue>*/() {
         public int compare(Object /*RubyValue*/ arg0, Object /*RubyValue*/ arg1) {
           RubyValue v =
               RubyAPI.callPublicOneArgMethod(
                   (RubyValue) arg0, (RubyValue) arg1, null, RubyID.unequalID);
           return ((RubyFixnum) v).toInt();
         }
       });
 }
Beispiel #2
0
  private void sort_with_block(final RubyBlock block) {
    final RubyArray self = this;
    Collections.sort(
        array_,
        new Comparator /*<RubyValue>*/() {

          public int compare(Object /*RubyValue*/ arg0, Object /*RubyValue*/ arg1) {
            // TODO can not check if block return/break occured.
            RubyValue v = block.invoke(self, (RubyValue) arg0, (RubyValue) arg1);
            return ((RubyFixnum) v).toInt();
          }
        });
  }
Beispiel #3
0
 // @RubyLevelMethod(name="reverse!")
 public RubyArray reverseBang() {
   Collections.reverse(array_);
   return this;
 }
Beispiel #4
0
 // @RubyLevelMethod(name="reverse")
 public RubyArray reverse() {
   RubyArray array = this.copy();
   Collections.reverse(array.array_);
   return array;
 }