java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyArray<T>
- Type Parameters:
T- What array holds
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,Iterable,Collection,List,RandomAccess,SequencedCollection,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
- Direct Known Subclasses:
RubyArrayNative
public abstract class RubyArray<T extends IRubyObject>
extends RubyObject
implements List, RandomAccess
The implementation of the built-in class Array in Ruby.
Concurrency: no synchronization is required among readers, but
all users must synchronize externally with writers.
Note: elt(long) is based on notion if we exceed precision by passing in a long larger
than int (actually Integer.MAX - 8) then it will just return nil. Anything using eltOk
must know this already to avoid an AIOOBE. We do catch that in eltOk but only as an
attempt at detecting concurrent modifications to the length. So if you improperly
use eltOk you will get a conc error and not AIOOBE.
Guidance for elt(long) is that if the Ruby method should raise if it is too large
then you need to do that before you call this (toLong vs getValue/asLong).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classNested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
FieldsFields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, ERR_INSECURE_SET_INST_VAR, FALSE_F, flags, FROZEN_F, metaClass, NEVER, NIL_F, STAMP_OFFSET, TAINTED_F, UNDEF, VAR_TABLE_OFFSET, varTable, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract IRubyObjectall_p(ThreadContext context, Block block) abstract IRubyObjectall_p(ThreadContext context, IRubyObject arg, Block block) abstract IRubyObjectany_p(ThreadContext context, Block block) abstract IRubyObjectany_p(ThreadContext context, IRubyObject arg, Block block) RubyArray<?> append(IRubyObject item) Deprecated.abstract RubyArrayappend(ThreadContext context, IRubyObject item) aref(IRubyObject[] args) Deprecated.Use the versions with zero, one, or two args.aref(IRubyObject arg0, IRubyObject arg1) Deprecated.abstract IRubyObjectaref(ThreadContext context, IRubyObject arg0) abstract IRubyObjectaref(ThreadContext context, IRubyObject arg0, IRubyObject arg1) Deprecated.abstract RubyArrayaryAppend(ThreadContext context, RubyArray<?> y) abstract RubyArrayaryDup()static RubyArrayaryToAry(ThreadContext context, IRubyObject obj) aset(IRubyObject[] args) Deprecated.Use the versions with zero, one, or two args.aset(IRubyObject arg0, IRubyObject arg1) Deprecated.aset(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Deprecated.abstract IRubyObjectaset(ThreadContext context, IRubyObject arg0, IRubyObject arg1) abstract IRubyObjectaset(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) abstract IRubyObjectassoc(ThreadContext context, IRubyObject key) at(IRubyObject pos) Deprecated.Useat(ThreadContext, IRubyObject)instead.abstract IRubyObjectat(ThreadContext context, IRubyObject pos) abstract IRubyObjectbsearch(ThreadContext context, Block block) abstract IRubyObjectbsearch_index(ThreadContext context, Block block) final IRubyObjectrb_check_array_type Returns the result of trying to convert this object to an Array with "to_ary".protected static final voidcheckLength(Ruby runtime, long length) Deprecated.static final intcheckLength(ThreadContext context, long length) abstract IRubyObjectcollect_bang(ThreadContext context, Block block) abstract IRubyObjectcombination(ThreadContext context, IRubyObject num, Block block) compact()Deprecated.abstract IRubyObjectcompact(ThreadContext context) Deprecated.abstract IRubyObjectcompact_bang(ThreadContext context) abstract RubyBooleancompare(ThreadContext context, CallSite site, IRubyObject other) abstract RubyArrayconcat(IRubyObject obj) abstract RubyArrayconcat(ThreadContext context, IRubyObject obj) abstract RubyArrayconcat(ThreadContext context, IRubyObject[] objs) final RubyArrayTries to convert this object to a Ruby Array using the "to_ary" method.voidcopyInto(IRubyObject[] target, int start) Deprecated.voidcopyInto(IRubyObject[] target, int start, int len) Deprecated.abstract voidcopyInto(ThreadContext context, IRubyObject[] target, int start) Copy the values contained in this array into the target array at the specified offset.abstract voidcopyInto(ThreadContext context, IRubyObject[] target, int start, int len) Copy the specified number of values contained in this array into the target array at the specified offset.abstract IRubyObjectcount(ThreadContext context, Block block) abstract IRubyObjectcount(ThreadContext context, IRubyObject obj, Block block) static IRubyObjectcreate(IRubyObject klass, IRubyObject[] args, Block block) Deprecated.static IRubyObjectcreate(ThreadContext context, IRubyObject klass, IRubyObject[] args, Block block) static RubyClasscreateArrayClass(ThreadContext context, RubyClass Object, RubyModule Enumerable) abstract IRubyObjectcycle(ThreadContext context, Block block) abstract IRubyObjectcycle(ThreadContext context, IRubyObject arg, Block block) final IRubyObjectdeconstruct(ThreadContext context) abstract IRubyObjectdelete(ThreadContext context, IRubyObject item, Block block) delete_at(int pos) Deprecated.delete_at(IRubyObject obj) Deprecated.abstract IRubyObjectdelete_at(ThreadContext context, int pos) abstract IRubyObjectdelete_at(ThreadContext context, IRubyObject obj) abstract IRubyObjectdelete_if(ThreadContext context, Block block) abstract IRubyObjectdifference(ThreadContext context, IRubyObject[] args) abstract IRubyObjectdig(ThreadContext context, IRubyObject arg0) abstract IRubyObjectdig(ThreadContext context, IRubyObject[] args) abstract IRubyObjectdig(ThreadContext context, IRubyObject arg0, IRubyObject arg1) abstract IRubyObjectdig(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) abstract IRubyObjectdrop(ThreadContext context, IRubyObject n) abstract IRubyObjectdrop_while(ThreadContext context, Block block) abstract IRubyObjecteach(ThreadContext context, Block block) abstract IRubyObjecteach_index(ThreadContext context, Block block) abstract IRubyObjecteach_slice(ThreadContext context, IRubyObject arg, Block block) abstract IRubyObjecteachSlice(ThreadContext context, int size, Block block) protected abstract IRubyObjectelt(long offset) abstract TeltInternal(int offset) abstract TeltInternalSet(int offset, T item) abstract TeltOk(long offset) abstract Tabstract Tempty_p()Deprecated.abstract IRubyObjectempty_p(ThreadContext context) abstract IRubyObjectentry(int offset) abstract IRubyObjectentry(long offset) abstract IRubyObjecteql(ThreadContext context, IRubyObject obj) abstract booleanThis override does not do a "checked" dispatch.fetch(ThreadContext context, IRubyObject[] args, Block block) Deprecated.Use the versions with zero, one, or two args.abstract IRubyObjectfetch(ThreadContext context, IRubyObject arg0, Block block) abstract IRubyObjectfetch(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) abstract IRubyObjectfetch_values(ThreadContext context, IRubyObject[] args, Block block) abstract IRubyObjectfill(ThreadContext context, Block block) abstract IRubyObjectfill(ThreadContext context, IRubyObject arg, Block block) abstract IRubyObjectfill(ThreadContext context, IRubyObject arg1, IRubyObject arg2, Block block) abstract IRubyObjectfill(ThreadContext context, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block block) abstract IRubyObjectfind(ThreadContext context, IRubyObject ifnone, Block block) abstract IRubyObjectfind_index(ThreadContext context, Block block) abstract IRubyObjectfind_index(ThreadContext context, IRubyObject cond) first()Deprecated.first(IRubyObject arg0) Deprecated.first(IRubyObject[] args) Deprecated.abstract IRubyObjectfirst(ThreadContext context) abstract IRubyObjectfirst(ThreadContext context, IRubyObject arg0) abstract IRubyObjectflatten(ThreadContext context) abstract IRubyObjectflatten(ThreadContext context, IRubyObject arg) abstract IRubyObjectflatten_bang(ThreadContext context) abstract IRubyObjectflatten_bang(ThreadContext context, IRubyObject arg) Will return the Java interface that most closely can represent this object, when working through Java integration translations.abstract intfinal List<IRubyObject> getList()Deprecated.RubyArray implements List, use it directlyThis is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.abstract RubyFixnumhash(ThreadContext context) Will return the hash code of this object.abstract RubyBooleaninclude_p(ThreadContext context, IRubyObject item) abstract booleanincludes(ThreadContext context, IRubyObject item) protected abstract booleanincludesByEql(ThreadContext context, IRubyObject item) abstract IRubyObjectindex(ThreadContext context, Block block) abstract IRubyObjectindex(ThreadContext context, IRubyObject obj) abstract IRubyObjectindex(ThreadContext context, IRubyObject obj, Block unused) indexes(IRubyObject[] args) Deprecated.indexes(ThreadContext context, IRubyObject[] args) Deprecated.abstract IRubyObjectinitialize(ThreadContext context, Block block) abstract IRubyObjectinitialize(ThreadContext context, IRubyObject arg0, Block block) abstract IRubyObjectinitialize(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) abstract IRubyObjectinitialize_copy(ThreadContext context, IRubyObject orig) Initializes this object as a copy of the original, that is the parameter to this object.insert(IRubyObject arg) Deprecated.insert(IRubyObject[] args) Deprecated.insert(IRubyObject arg1, IRubyObject arg2) Deprecated.abstract IRubyObjectinsert(ThreadContext context, IRubyObject arg) abstract IRubyObjectinsert(ThreadContext context, IRubyObject[] args) abstract IRubyObjectinsert(ThreadContext context, IRubyObject arg1, IRubyObject arg2) abstract RubyStringinspect(ThreadContext context) Returns a string containing a human-readable representation of obj.abstract IRubyObjectintersect_p(ThreadContext context, IRubyObject other) abstract IRubyObjectintersection(ThreadContext context, IRubyObject[] args) abstract booleanisSharedJavaArray(RubyArray other) abstract IRubyObjectjoin(ThreadContext context) abstract IRubyObjectjoin(ThreadContext context, IRubyObject sep) join19(ThreadContext context) Deprecated.join19(ThreadContext context, IRubyObject sep) Deprecated.abstract IRubyObjectkeep_if(ThreadContext context, Block block) last()Deprecated.last(IRubyObject arg0) Deprecated.last(IRubyObject[] args) Deprecated.Use the versions with zero, one, or two args.abstract IRubyObjectlast(ThreadContext context) abstract IRubyObjectlast(ThreadContext context, IRubyObject arg0) length()Deprecated.abstract RubyFixnumlength(ThreadContext context) protected abstract RubyHashprotected abstract RubyHashabstract IRubyObjectmap(ThreadContext context, Block block) abstract IRubyObjectmap_bang(ThreadContext context, Block block) static voidmarshalTo(RubyArray array, MarshalStream output) Deprecated, for removal: This API element is subject to removal in a future version.static voidmarshalTo(ThreadContext context, RubyArray array, MarshalStream output) Deprecated, for removal: This API element is subject to removal in a future version.static voidmarshalTo(ThreadContext context, RubyOutputStream out, RubyArray array, MarshalDumper output) abstract IRubyObjectmax(ThreadContext context, Block block) abstract IRubyObjectmax(ThreadContext context, IRubyObject num, Block block) abstract IRubyObjectmin(ThreadContext context, Block block) abstract IRubyObjectmin(ThreadContext context, IRubyObject num, Block block) abstract IRubyObjectminmax(ThreadContext context, Block block) static final RubyArray<?> Deprecated.static RubyArray<?> static RubyArray<?> newArray(Ruby runtime, Collection<? extends IRubyObject> collection) static RubyArray<?> newArray(Ruby runtime, List<? extends IRubyObject> list) static RubyArray<?> newArray(Ruby runtime, IRubyObject obj) static RubyArray<?> newArray(Ruby runtime, IRubyObject[] args) static RubyArray<?> newArray(Ruby runtime, IRubyObject car, IRubyObject cdr) static RubyArray<?> newArray(Ruby runtime, IRubyObject first, IRubyObject second, IRubyObject third) static RubyArray<?> newArray(Ruby runtime, IRubyObject first, IRubyObject second, IRubyObject third, IRubyObject fourth) static RubyArray<?> newArray(ThreadContext context) static RubyArray<?> newArray(ThreadContext context, int len) static RubyArray<?> newArrayLight(Ruby runtime) static RubyArray<?> newArrayLight(RubyClass arrayClass, IRubyObject obj) static RubyArray<?> newArrayLight(RubyClass arrayClass, IRubyObject car, IRubyObject cdr) static RubyArray<?> newArrayLight(Ruby runtime, int len) static RubyArray<?> newArrayLight(Ruby runtime, IRubyObject obj) static RubyArray<?> newArrayLight(Ruby runtime, IRubyObject... objs) static RubyArray<?> newArrayLight(Ruby runtime, IRubyObject car, IRubyObject cdr) static RubyArraynewArrayMayCopy(Ruby runtime, IRubyObject... args) static RubyArraynewArrayMayCopy(Ruby runtime, IRubyObject[] args, int start) static RubyArraynewArrayMayCopy(Ruby runtime, IRubyObject[] args, int start, int length) Construct a new RubyArray given the specified range of elements in the source array.static RubyArraynewArrayNoCopy(Ruby runtime, IRubyObject... args) static RubyArraynewArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin) static RubyArraynewArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin, int length) static RubyArraynewArrayNoCopyLight(Ruby runtime, IRubyObject[] args) static RubyArraynewBlankArray(Ruby runtime, int size) Deprecated.static RubyArraynewBlankArray(ThreadContext context, int size) Construct the most efficient array shape for the given size.static RubyArray<?> newEmptyArray(Ruby runtime) static RubyArray<?> newEmptyArray(Ruby runtime, RubyClass klass) static RubyArray<?> newSharedArray(RubyClass arrayClass, IRubyObject[] shared) nitems()Deprecated.abstract IRubyObjectnitems(ThreadContext context) abstract IRubyObjectnone_p(ThreadContext context, Block block) abstract IRubyObjectnone_p(ThreadContext context, IRubyObject arg, Block block) abstract IRubyObjectone_p(ThreadContext context, Block block) abstract IRubyObjectone_p(ThreadContext context, IRubyObject arg, Block block) op_and(IRubyObject other) Deprecated.abstract IRubyObjectop_and(ThreadContext context, IRubyObject other) abstract IRubyObjectop_cmp(ThreadContext context, IRubyObject obj) op_diff(IRubyObject other) Deprecated.abstract IRubyObjectop_diff(ThreadContext context, IRubyObject other) abstract IRubyObjectop_equal(ThreadContext context, IRubyObject obj) rb_obj_equal Will by default use identity equality to compare objects.op_or(IRubyObject other) Deprecated.abstract IRubyObjectop_or(ThreadContext context, IRubyObject other) op_plus(IRubyObject obj) Deprecated.abstract IRubyObjectop_plus(ThreadContext context, IRubyObject obj) abstract IRubyObjectop_times(ThreadContext context, IRubyObject times) abstract RubyStringpack(ThreadContext context, IRubyObject obj) abstract RubyStringpack(ThreadContext context, IRubyObject obj, IRubyObject maybeOpts) abstract IRubyObjectpermutation(ThreadContext context, Block block) abstract IRubyObjectpermutation(ThreadContext context, IRubyObject num, Block block) abstract IRubyObjectpop(ThreadContext context) abstract IRubyObjectpop(ThreadContext context, IRubyObject num) abstract IRubyObjectproduct(ThreadContext context, IRubyObject[] args, Block block) push(IRubyObject item) Deprecated.RubyArray<?> push(IRubyObject[] items) Deprecated.abstract RubyArraypush(ThreadContext context, IRubyObject item) abstract RubyArraypush(ThreadContext context, IRubyObject[] items) RubyArray<?> push_m(IRubyObject[] items) Deprecated.abstract IRubyObjectrassoc(ThreadContext context, IRubyObject value) rb_clear()Deprecated.abstract IRubyObjectrb_clear(ThreadContext context) abstract IRubyObjectrbCollect(ThreadContext context, Block block) abstract IRubyObjectreject(ThreadContext context, Block block) abstract IRubyObjectreject_bang(ThreadContext context, Block block) abstract IRubyObjectrepeated_permutation(ThreadContext context, IRubyObject num, Block block) abstract IRubyObjectrepeatedCombination(ThreadContext context, IRubyObject num, Block block) replace(IRubyObject orig) Deprecated.abstract IRubyObjectreplace(ThreadContext context, IRubyObject orig) reverse()Deprecated.abstract IRubyObjectreverse(ThreadContext context) Deprecated.abstract IRubyObjectreverse_bang(ThreadContext context) abstract IRubyObjectreverse_each(ThreadContext context, Block block) abstract IRubyObjectrfind(ThreadContext context, Block block) abstract IRubyObjectrfind(ThreadContext context, IRubyObject ifnone, Block block) abstract IRubyObjectrindex(ThreadContext context, Block block) abstract IRubyObjectrindex(ThreadContext context, IRubyObject obj, Block unused) abstract IRubyObjectrotate(ThreadContext context) abstract IRubyObjectrotate(ThreadContext context, IRubyObject cnt) abstract IRubyObjectrotate_bang(ThreadContext context) abstract IRubyObjectrotate_bang(ThreadContext context, IRubyObject cnt) abstract Stream<IRubyObject> Returns a stream of each IRubyObjectabstract IRubyObjectsample(ThreadContext context) abstract IRubyObjectsample(ThreadContext context, IRubyObject sampleOrOpts) abstract IRubyObjectsample(ThreadContext context, IRubyObject sample, IRubyObject opts) abstract IRubyObjectselect(ThreadContext context, Block block) abstract IRubyObjectselect_bang(ThreadContext context, Block block) abstract IRubyObjectshift(ThreadContext context) abstract IRubyObjectshift(ThreadContext context, IRubyObject num) abstract IRubyObjectshuffle(ThreadContext context) abstract IRubyObjectshuffle(ThreadContext context, IRubyObject opts) abstract IRubyObjectshuffle_bang(ThreadContext context) abstract IRubyObjectshuffle_bang(ThreadContext context, IRubyObject opts) protected static IRubyObjectsize(ThreadContext context, RubyArray self, IRubyObject[] args) A size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])slice_bang(IRubyObject arg0) Deprecated.slice_bang(IRubyObject[] args) Deprecated.Use the versions with zero, one, or two args.slice_bang(IRubyObject arg0, IRubyObject arg1) Deprecated.abstract IRubyObjectslice_bang(ThreadContext context, IRubyObject arg0) abstract IRubyObjectslice_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1) abstract RubyArraysort(ThreadContext context, Block block) abstract IRubyObjectsort_bang(ThreadContext context, Block block) abstract IRubyObjectsort_by_bang(ThreadContext context, Block block) abstract IRubyObjectstore(long index, IRubyObject value) abstract IRubyObjectstore(ThreadContext context, long index, IRubyObject value) Store an element at the specified index or throw if the index is invalid.protected abstract voidstoreInternal(ThreadContext context, int index, IRubyObject value) abstract IRubyObjectabstract IRubyObjectsubseqLight(long beg, long len) abstract IRubyObjectsum(ThreadContext context, Block block) abstract IRubyObjectsum(ThreadContext context, IRubyObject init, Block block) abstract IRubyObjecttake(ThreadContext context, IRubyObject n) abstract IRubyObjecttake_while(ThreadContext context, Block block) abstract RubyArrayto_a(ThreadContext context) to_ary()Deprecated.final IRubyObjectto_ary(ThreadContext context) abstract IRubyObjectto_h(ThreadContext context, Block block) abstract RubyStringto_s(ThreadContext context) Deprecated.UsetoJavaArray(ThreadContext)instead.abstract IRubyObject[]toJavaArray(ThreadContext context) Return a Java array copy of the elements contained in this Array.abstract IRubyObject[]Return a Java array of the elements contained in this array, possibly a new array object.abstract IRubyObject[]Return a reference to this RubyArray's underlying Java array, if it is not shared with another RubyArray, or an exact copy of the relevant range otherwise.Deprecated.abstract RubyArraytranspose(ThreadContext context) static IRubyObjecttry_convert(ThreadContext context, IRubyObject self, IRubyObject arg) abstract IRubyObjectunion(ThreadContext context, IRubyObject[] args) protected abstract voidunionInternal(ThreadContext context, RubyArray... args) abstract IRubyObjectuniq(ThreadContext context, Block block) abstract IRubyObjectuniq_bang(ThreadContext context, Block block) static RubyArrayunmarshalFrom(UnmarshalStream input) Deprecated, for removal: This API element is subject to removal in a future version.static RubyArrayunmarshalFrom(ThreadContext context, RubyInputStream in, MarshalLoader input) unshift()Deprecated.unshift(IRubyObject item) Deprecated.unshift(IRubyObject[] items) Deprecated.abstract IRubyObjectunshift(ThreadContext context) abstract IRubyObjectunshift(ThreadContext context, IRubyObject item) abstract IRubyObjectunshift(ThreadContext context, IRubyObject[] items) values_at(IRubyObject[] args) Deprecated.abstract IRubyObjectvalues_at(ThreadContext context, IRubyObject[] args) abstract IRubyObjectzip(ThreadContext context, IRubyObject[] args, Block block) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, dig, dig1, dig2, eqlInternal, equalInternal, finishObjectClass, hashCode, inspect, op_eqq, puts, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
__id__, addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, eql_p, equal_p, evalUnder, extend, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getMarshalVariableList, getMetaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableList, getVariableNameList, hash, hashyInspect, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_s, toJava, type, untaint, validateInstanceVariable, variableTableContains, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariablesMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Field Details
-
DEFAULT_INSPECT_STR_SIZE
public static final int DEFAULT_INSPECT_STR_SIZE- See Also:
-
-
Constructor Details
-
RubyArray
-
RubyArray
-
RubyArray
-
-
Method Details
-
createArrayClass
public static RubyClass createArrayClass(ThreadContext context, RubyClass Object, RubyModule Enumerable) -
getNativeClassIndex
Description copied from class:RubyObjectThis is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex- Specified by:
getNativeClassIndexin interfaceCoreObjectType- Overrides:
getNativeClassIndexin classRubyObject- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
-
create
@Deprecated(since="10.0.0.0") public static IRubyObject create(IRubyObject klass, IRubyObject[] args, Block block) Deprecated. -
create
public static IRubyObject create(ThreadContext context, IRubyObject klass, IRubyObject[] args, Block block) -
newArray
-
newArray
-
newArrayLight
-
newArray
Deprecated. -
newArray
-
newArrayLight
-
newArray
-
newArrayLight
-
newArrayLight
-
newArrayLight
-
newArrayLight
-
newArrayLight
-
newArray
-
newArray
public static RubyArray<?> newArray(Ruby runtime, IRubyObject first, IRubyObject second, IRubyObject third) -
newArray
public static RubyArray<?> newArray(Ruby runtime, IRubyObject first, IRubyObject second, IRubyObject third, IRubyObject fourth) -
newEmptyArray
-
newEmptyArray
-
newArray
-
newArray
-
newArray
-
newArrayMayCopy
-
newArrayMayCopy
-
newArrayMayCopy
Construct a new RubyArray given the specified range of elements in the source array. The elements may be copied into a new backing store, and therefore you should not expect future changes to the source array to be reflected. Conversely, you should not modify the array after passing it, since the contents may not be copied.- Parameters:
runtime- the runtimeargs- the argsstart- start indexlength- number of elements- Returns:
- an array referencing the given elements
-
newArrayNoCopy
-
newArrayNoCopy
-
newArrayNoCopy
-
newArrayNoCopyLight
-
checkLength
Deprecated. -
checkLength
-
getList
Deprecated.RubyArray implements List, use it directly- Returns:
- a read-only copy of this list
-
getLength
public abstract int getLength() -
toJavaArray
Deprecated.UsetoJavaArray(ThreadContext)instead.- Returns:
- ""
-
toJavaArray
Return a Java array copy of the elements contained in this Array. This version always creates a new Java array that is exactly the length of the Array's elements.- Returns:
- a Java array with exactly the size and contents of this RubyArray's elements
-
toJavaArrayUnsafe
Return a reference to this RubyArray's underlying Java array, if it is not shared with another RubyArray, or an exact copy of the relevant range otherwise. This method is typically used to work with the underlying array directly, knowing that it is not shared and that all accesses must consider the begin offset.- Returns:
- The underlying Java array for this RubyArray, or a copy if that array is shared.
-
toJavaArrayMaybeUnsafe
Return a Java array of the elements contained in this array, possibly a new array object. Use this method to potentially avoid making a new array and copying elements when the Array does not view a subset of the underlying Java array.- Returns:
- a Java array with exactly the size and contents of this RubyArray's elements, possibly the actual underlying array.
-
initialize
-
initialize
-
initialize
public abstract IRubyObject initialize(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) -
initialize_copy
Description copied from class:RubyBasicObjectInitializes this object as a copy of the original, that is the parameter to this object. Will make sure that the argument actually has the same real class as this object. It shouldn't be possible to initialize an object with something totally different.- Overrides:
initialize_copyin classRubyBasicObject- Parameters:
context- the thread contextorig- the original- Returns:
- a copy unless the same thing
-
aryDup
-
replace
Deprecated. -
replace
-
to_s
- Overrides:
to_sin classRubyBasicObject
-
includes
-
includesByEql
-
hash
Description copied from class:RubyBasicObjectWill return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintenance.- Overrides:
hashin classRubyBasicObject- Parameters:
context- the current thread context- Returns:
- the hash value
-
store
-
store
Store an element at the specified index or throw if the index is invalid.- Parameters:
context- the current thread contextindex- the offset to store the valuevalue- the value to be stored- Returns:
- the value set
-
storeInternal
-
elt
-
eltOk
-
eltSetOk
-
eltSetOk
-
entry
-
entry
-
eltInternal
-
eltInternalSet
-
fetch
@Deprecated(since="9.4-") public IRubyObject fetch(ThreadContext context, IRubyObject[] args, Block block) Deprecated.Use the versions with zero, one, or two args.Variable arity version for compatibility. Not bound to a Ruby method. -
fetch_values
-
fetch
-
fetch
public abstract IRubyObject fetch(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) -
aryToAry
-
insert
Deprecated. -
insert
-
insert
Deprecated. -
insert
-
insert
Deprecated. -
insert
-
transpose
Deprecated. -
transpose
-
values_at
Deprecated. -
values_at
-
subseqLight
-
subseq
-
length
-
length
Deprecated. -
size
A size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])- See Also:
-
append
Deprecated. -
append
-
push_m
Deprecated. -
push
Deprecated. -
push
-
push
Deprecated. -
push
-
pop
-
pop
-
shift
-
shift
-
unshift
Deprecated. -
unshift
-
unshift
Deprecated. -
unshift
-
unshift
Deprecated. -
unshift
-
include_p
-
aref
Deprecated.Use the versions with zero, one, or two args.Variable arity version for compatibility. Not bound to a Ruby method. -
aref
-
aref
Deprecated. -
aref
-
aset
Deprecated.Use the versions with zero, one, or two args.Variable arity version for compatibility. Not bound to a Ruby method. -
aset
Deprecated. -
aset
@Deprecated(since="10.0.0.0") public IRubyObject aset(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Deprecated.- Parameters:
arg0-arg1-arg2-- Returns:
- ""
-
aset
-
aset
public abstract IRubyObject aset(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
at
Deprecated.Useat(ThreadContext, IRubyObject)instead.- Parameters:
pos-- Returns:
- ""
-
at
-
concat
-
aryAppend
Deprecated. -
aryAppend
-
concat
-
concat
-
inspect
Description copied from class:RubyBasicObjectReturns a string containing a human-readable representation of obj. If not overridden, uses theto_smethod to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspectin interfaceIRubyObject- Overrides:
inspectin classRubyBasicObject
-
first
Deprecated. -
first
Deprecated. -
first
-
first
Deprecated. -
first
-
last
Deprecated.Use the versions with zero, one, or two args.Variable arity version for compatibility. Not bound to a Ruby method. -
last
Deprecated. -
last
-
last
Deprecated. -
last
-
each
-
eachSlice
-
each_slice
-
each_index
-
reverse_each
-
join19
Deprecated. -
join
-
join19
Deprecated. -
join
-
to_a
- Overrides:
to_ain classRubyBasicObject
-
to_ary
Deprecated. -
to_ary
-
to_h
-
convertToArray
Description copied from class:RubyBasicObjectTries to convert this object to a Ruby Array using the "to_ary" method.- Specified by:
convertToArrayin interfaceIRubyObject- Overrides:
convertToArrayin classRubyBasicObject- Returns:
- array representation of this
-
checkArrayType
Description copied from class:RubyBasicObjectrb_check_array_type Returns the result of trying to convert this object to an Array with "to_ary".- Specified by:
checkArrayTypein interfaceIRubyObject- Overrides:
checkArrayTypein classRubyBasicObject- Returns:
- nil if type check failed
-
op_equal
Description copied from class:RubyBasicObjectrb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics. The name of this method doesn't follow the convention because hierarchy problems- Specified by:
op_equalin interfaceIRubyObject- Overrides:
op_equalin classRubyBasicObject
-
compare
-
eql
-
compact_bang
Deprecated.- Returns:
- ""
-
compact_bang
-
compact
Deprecated. -
compact
-
empty_p
Deprecated. -
empty_p
-
rb_clear
Deprecated. -
rb_clear
-
fill
-
fill
-
fill
public abstract IRubyObject fill(ThreadContext context, IRubyObject arg1, IRubyObject arg2, Block block) -
fill
public abstract IRubyObject fill(ThreadContext context, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block block) -
index
-
index
-
index
-
bsearch
-
bsearch_index
-
rindex
-
rindex
-
indexes
Deprecated. -
indexes
Deprecated. -
reverse_bang
Deprecated. -
reverse_bang
-
reverse
Deprecated. -
reverse
-
rbCollect
-
map
-
collect_bang
-
map_bang
-
select
-
select_bang
-
keep_if
-
deconstruct
-
delete
-
delete_at
Deprecated. -
delete_at
-
delete_at
Deprecated. -
delete_at
-
reject
-
reject_bang
-
delete_if
-
zip
-
op_cmp
- Overrides:
op_cmpin classRubyBasicObject
-
slice_bang
Deprecated.Use the versions with zero, one, or two args.Variable arity version for compatibility. Not bound to a Ruby method. -
slice_bang
Deprecated. -
slice_bang
-
slice_bang
Deprecated. -
slice_bang
-
assoc
-
rassoc
-
flatten_bang
-
flatten_bang
-
flatten
-
flatten
-
count
-
count
-
nitems
-
nitems
Deprecated. -
op_plus
Deprecated. -
op_plus
-
op_times
-
makeHash
-
makeHash
-
uniq_bang
-
uniq
-
op_diff
Deprecated. -
op_diff
-
difference
-
intersection
-
intersect_p
-
op_and
Deprecated. -
op_and
-
op_or
Deprecated. -
op_or
-
union
-
unionInternal
-
sort
-
sort_bang
-
sort_by_bang
-
take
-
take_while
-
drop
-
drop_while
-
cycle
-
cycle
-
product
-
combination
-
repeatedCombination
public abstract IRubyObject repeatedCombination(ThreadContext context, IRubyObject num, Block block) -
permutation
-
permutation
-
repeated_permutation
public abstract IRubyObject repeated_permutation(ThreadContext context, IRubyObject num, Block block) -
shuffle_bang
-
shuffle_bang
-
shuffle
-
shuffle
-
sample
-
sample
-
sample
-
rotate_bang
-
rotate_bang
-
rotate
-
rotate
-
all_p
-
all_p
-
any_p
-
any_p
-
none_p
-
none_p
-
one_p
-
one_p
-
sum
-
sum
-
find
-
find_index
-
find_index
-
newBlankArray
Deprecated. -
newBlankArray
Construct the most efficient array shape for the given size. This should only be used when you intend to populate all elements, since the packed arrays will be born with a nonzero size and would have to be unpacked to partially populate. We nil-fill all cases, to ensure nulls will never leak out if there's an unpopulated element or an index accessed before assignment.- Parameters:
context- the current thread contextsize- the size- Returns:
- a RubyArray shaped for the given size
-
try_convert
-
pack
-
pack
-
dig
-
dig
-
dig
public abstract IRubyObject dig(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
dig
-
max
-
max
-
min
-
min
-
minmax
-
getJavaClass
Description copied from class:RubyBasicObjectWill return the Java interface that most closely can represent this object, when working through Java integration translations.- Specified by:
getJavaClassin interfaceIRubyObject- Overrides:
getJavaClassin classRubyBasicObject- Returns:
- the true Java class of this (Ruby) object
-
copyInto
Deprecated. -
copyInto
Copy the values contained in this array into the target array at the specified offset. It is expected that the target array is large enough to hold all necessary values. -
copyInto
Deprecated. -
copyInto
Copy the specified number of values contained in this array into the target array at the specified offset. It is expected that the target array is large enough to hold all necessary values. -
equals
Description copied from class:RubyObjectThis override does not do a "checked" dispatch.- Specified by:
equalsin interfaceCollection<T extends IRubyObject>- Specified by:
equalsin interfaceList<T extends IRubyObject>- Overrides:
equalsin classRubyObject- Parameters:
other- object to compare- Returns:
- true if equals
- See Also:
-
rfind
-
rfind
-
marshalTo
@Deprecated(since="10.0.0.0", forRemoval=true) public static void marshalTo(RubyArray array, MarshalStream output) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
marshalTo
@Deprecated(since="10.0.0.0", forRemoval=true) public static void marshalTo(ThreadContext context, RubyArray array, MarshalStream output) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
marshalTo
public static void marshalTo(ThreadContext context, RubyOutputStream out, RubyArray array, MarshalDumper output) -
unmarshalFrom
@Deprecated(since="10.0.0.0", forRemoval=true) public static RubyArray unmarshalFrom(UnmarshalStream input) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
unmarshalFrom
public static RubyArray unmarshalFrom(ThreadContext context, RubyInputStream in, MarshalLoader input) -
rubyStream
Returns a stream of each IRubyObject- Returns:
-