Class RubyArraySpecialized

All Implemented Interfaces:
Serializable, Cloneable, Comparable, Iterable, Collection, List, RandomAccess, SequencedCollection, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
Direct Known Subclasses:
RubyArrayOneObject, RubyArrayTwoObject

public abstract class RubyArraySpecialized extends RubyArray

This is the base class for all specialized RubyArray.

Specialized RubyArray use fields rather than an IRubyObject[] to hold their values. When they need to grow or shrink, they unpack those values to a proper IRubyObject[] and fall back on RubyArray logic.

Subclasses should override all methods that would access the array directly to use the fields, with guards for the packed flag and access outside packed range. This includes the following methods (at the time of this writing...this list will evolve):

RubyArrayRubyArray.eltInternal(int) RubyArrayRubyArray.eltInternalSet(int index, IRubyObject value) RubyArraySpecializedfinishUnpack(IRubyObject nil) RubyArrayRubyArray.aryDup() RubyArrayRubyArray.rb_clear(org.jruby.runtime.ThreadContext) RubyArrayRubyArray.collect(org.jruby.runtime.ThreadContext, org.jruby.runtime.Block) RubyArrayRubyArray.copyInto(org.jruby.runtime.ThreadContext,IRubyObject[], int) RubyArrayRubyArray.copyInto(org.jruby.runtime.ThreadContext,IRubyObject[], int, int) RubyArrayRubyArray.dupImpl(Ruby, RubyClass) RubyArrayRubyArray.includes(org.jruby.runtime.ThreadContext, IRubyObject) RubyArrayRubyArray.indexOf(Object) RubyArrayRubyArray.inspectAry(org.jruby.runtime.ThreadContext) RubyArrayRubyArray.internalRotate(org.jruby.runtime.ThreadContext, int) RubyArrayRubyArray.internalRotateBang(org.jruby.runtime.ThreadContext, int) RubyArrayRubyArray.op_plus(org.jruby.runtime.ThreadContext, IRubyObject) RubyArrayRubyArray.reverse_bang(org.jruby.runtime.ThreadContext) RubyArrayRubyArray.safeReverse() RubyArrayRubyArray.sortInternal(org.jruby.runtime.ThreadContext, org.jruby.runtime.Block) RubyArrayRubyArray.sortInternal(org.jruby.runtime.ThreadContext, boolean) RubyArrayRubyArray.storeInternal(org.jruby.runtime.ThreadContext, int, IRubyObject) RubyArrayRubyArray.subseq(RubyClass, long, long, boolean) RubyArrayRubyArray.toJavaArray(ThreadContext) RubyArrayRubyArray.uniq(org.jruby.runtime.ThreadContext)
See Also:
  • Field Details

  • Constructor Details

    • RubyArraySpecialized

      public RubyArraySpecialized(Ruby runtime, boolean light)
    • RubyArraySpecialized

      public RubyArraySpecialized(RubyClass otherClass, boolean light)
    • RubyArraySpecialized

      public RubyArraySpecialized(RubyClass otherClass)
  • Method Details

    • unpack

      protected final void unpack(ThreadContext context)
      Description copied from class: RubyArray
      Overridden by specialized arrays to fall back to IRubyObject[].
      Overrides:
      unpack in class RubyArray
    • finishUnpack

      protected abstract void finishUnpack(IRubyObject nil)
    • packed

      protected boolean packed()