Top Description Inners Fields Constructors Methods
org.jruby

public Class RubyArray<T extends IRubyObject>

extends RubyObject
implements List, RandomAccess
Class Inheritance
All Implemented Interfaces
java.util.RandomAccess, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
org.jruby.RubyClass.SubclassArray, org.jruby.specialized.RubyArraySpecialized, org.jruby.util.collections.StringArraySet
Annotations
@JRubyClass
name:Array
include:Enumerable
overrides:RubyArrayOneObject, RubyArrayTwoObject, StringArraySet
Type Parameters
<T>
What array holds
Imports
java.io.IOException, java.lang.reflect.Array, java.math.BigInteger, java.util.Arrays, .BitSet, .Collection, .Comparator, .IdentityHashMap, .Iterator, .List, .ListIterator, .RandomAccess, .Stack, java.util.stream.Stream, org.jcodings.specific.USASCIIEncoding, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Create, .JRubyAPI, org.jruby.ast.util.ArgsUtil, org.jruby.exceptions.RaiseException, org.jruby.java.util.ArrayUtils, org.jruby.javasupport.JavaUtil, org.jruby.runtime.Arity, .Block, .CallSite, .ClassIndex, .Helpers, .JavaSites, .JavaSites.ArraySites, .Signature, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.callsite.CacheEntry, .CachingCallSite, org.jruby.runtime.encoding.EncodingCapable, org.jruby.runtime.marshal.MarshalDumper, .MarshalLoader, org.jruby.specialized.RubyArrayOneObject, .RubyArraySpecialized, .RubyArrayTwoObject, org.jruby.util.ArraySupport, .ByteList, .Pack, .RecursiveComparator, .TypeConverter, org.jruby.util.cli.Options, org.jruby.util.collections.StringArraySet, org.jruby.util.io.EncodingUtils, .RubyInputStream, .RubyOutputStream

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).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
pack-priv static class
public static class
private static class
public class
pack-priv class

Field Summary

Modifier and TypeField and Description
public static final int
protected int
public static final int
private volatile boolean
private static final RubyArray.JoinRecursive
protected int
private static final int
private static final int
private static final int
private static final int
private static final boolean
protected IRubyObject[]
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
private
RubyArray(Ruby runtime, IRubyObject[] vals)

private
RubyArray(Ruby runtime, IRubyObject[] vals, boolean objectSpace)

public
RubyArray(Ruby runtime, IRubyObject[] vals, int begin, int length)

private
RubyArray(Ruby runtime, RubyClass metaClass, IRubyObject[] vals, int begin, int length, boolean objectSpace)

public
RubyArray(Ruby runtime, int length)

private
RubyArray(Ruby runtime, boolean objectSpace)

protected
RubyArray(Ruby runtime, RubyClass klass)

private
RubyArray(Ruby runtime, RubyClass klass, int length)

private
RubyArray(Ruby runtime, RubyClass klass, IRubyObject[] vals, boolean objectspace)

protected
RubyArray(Ruby runtime, RubyClass klass, boolean objectSpace)

public
RubyArray(Ruby runtime, RubyClass klass, IRubyObject[] vals)

public
RubyArray(RubyClass klass, IRubyObject[] vals, boolean shared)

Method Summary

Modifier and TypeMethod and Description
public boolean
add(Object
element to be appended to this list
element
)

Implements java.util.List.add.

Appends the specified element to the end of this list (optional operation).

public boolean
add(ThreadContext context, Object element)

public void
add(int
index at which the specified element is to be inserted
index
,
Object
element to be inserted
element
)

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).

public boolean
addAll(Collection<E>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

public boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<E>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).

public IRubyObject
all_p(ThreadContext context, Block block)

public IRubyObject
all_p(ThreadContext context, IRubyObject arg, Block block)

private IRubyObject
public IRubyObject
private void
alloc(ThreadContext context, int length)

public IRubyObject
any_p(ThreadContext context, Block block)

public IRubyObject
any_p(ThreadContext context, IRubyObject arg, Block block)

private IRubyObject
public IRubyObject
public RubyArray<?>
append(IRubyObject item)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
append(ThreadContext context, IRubyObject item)

rb_ary_push - specialized rb_ary_store

public IRubyObject
aref(IRubyObject[] args)
Deprecated since 9.4. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
aref(IRubyObject arg0)
Deprecated

public IRubyObject
aref(ThreadContext context, IRubyObject arg0)

rb_ary_aref

public IRubyObject
aref(IRubyObject arg0, IRubyObject arg1)
Deprecated since 10.0.

public IRubyObject
private IRubyObject
public RubyArray<T extends IRubyObject>
aryAppend(RubyArray<T extends IRubyObject> y)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
public RubyArray<T extends IRubyObject>
aryDup()

rb_ary_dup

private static void
aryReverse(IRubyObject[] _p1, int p1, IRubyObject[] _p2, int p2)

public static RubyArray<T extends IRubyObject>
aryToAry(ThreadContext context, IRubyObject obj)

rb_ary_to_ary

public static RubyArray<T extends IRubyObject>
aryToAry(IRubyObject obj)
Deprecated

public IRubyObject
aset(IRubyObject[] args)
Deprecated since 9.4-. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
aset(IRubyObject arg0, IRubyObject arg1)
Deprecated since 10.0.

public IRubyObject
public IRubyObject
public IRubyObject
aset(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)

rb_ary_aset

private void
public IRubyObject
assoc(ThreadContext context, IRubyObject key)

rb_ary_assoc

public IRubyObject

Returns:

""
at
(IRubyObject pos)

public IRubyObject
at(ThreadContext context, IRubyObject pos)

rb_ary_at

private static IRubyObject
binomialCoefficient(ThreadContext context, long comb, long size)

public IRubyObject
bsearch(ThreadContext context, Block block)

public IRubyObject
private int
public IRubyObject
checkArrayType()

Overrides org.jruby.RubyBasicObject.checkArrayType.

Implements org.jruby.runtime.builtin.IRubyObject.checkArrayType.

rb_check_array_type Returns the result of trying to convert this object to an Array with "to_ary".

protected static final void
checkLength(Ruby runtime, long length)
Deprecated since 10.0.

public static final int
checkLength(ThreadContext context, long length)

private int
checkLongForInt(ThreadContext context, long value)

public void
clear()

Implements java.util.List.clear.

Removes all of the elements from this list (optional operation).

private void
clearValues(ThreadContext context, final int from, final int to)

private IRubyObject
cmpCommon(ThreadContext context, RubyArray<T extends IRubyObject> ary2)

public RubyArray<T extends IRubyObject>
collect(ThreadContext context, Block block)

public IRubyObject
collect_bang(ThreadContext context, Block block)

rb_ary_collect_bang

public RubyArray<T extends IRubyObject>

Returns:

an array of the filtered or unfiltered results
collectArray
(ThreadContext
the current context
context
,
Block
a block for filtering or NULL_BLOCK
block
)

Collect the contents of this array after filtering through block, or return a new equivalent array if the block is not given (!isGiven()).

public RubyArray<T extends IRubyObject>
collectBang(ThreadContext context, Block block)

rb_ary_collect_bang

public RubyEnumerator

Returns:

an enumerator that will filter results
collectEnum
(ThreadContext
the current context
context
)

Produce a new enumerator that will filter the contents of this array using collectArray(ThreadContext, Block).

private static void
combinate(ThreadContext context, int len, int n, int[] stack, RubyArray<T extends IRubyObject> values, Block block)

public IRubyObject
combination(ThreadContext context, IRubyObject num, Block block)

rb_ary_combination

private static IRubyObject
combinationSize(ThreadContext context, RubyArray<T extends IRubyObject> self, IRubyObject[] args)

A combination size method suitable for method reference implementation of SizeFnsize(ThreadContext, RubyArray, IRubyObject[]).

public IRubyObject
compact()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
public IRubyObject
compact_bang(ThreadContext context)

rb_ary_compact_bang

public RubyBoolean
compare(ThreadContext context, CallSite site, IRubyObject other)

protected static int
protected static int
public RubyArray<T extends IRubyObject>
concat(ThreadContext context, IRubyObject obj)

rb_ary_concat

private void
concat(ThreadContext context, RubyArray<?> obj)

public RubyArray<T extends IRubyObject>
concat(ThreadContext context, IRubyObject[] objs)

rb_ary_concat_multi

public RubyArray<T extends IRubyObject>
protected final void
private static RuntimeException
public boolean
contains(Object
element whose presence in this list is to be tested
element
)

Implements java.util.List.contains.

Returns true if this list contains the specified element.

public boolean
containsAll(Collection<E>
collection to be checked for containment in this list
c
)

Implements java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.

public RubyArray<T extends IRubyObject>
convertToArray()

Overrides org.jruby.RubyBasicObject.convertToArray.

Implements org.jruby.runtime.builtin.IRubyObject.convertToArray.

Tries to convert this object to a Ruby Array using the "to_ary" method.

public void
copyInto(IRubyObject[] target, int start)
Deprecated since 10.0.

public void
copyInto(ThreadContext context, IRubyObject[] target, int start)

Copy the values contained in this array into the target array at the specified offset.

public void
copyInto(IRubyObject[] target, int start, int len)
Deprecated since 10.0.

public void
copyInto(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.

public IRubyObject
count(ThreadContext context, Block block)

public IRubyObject
count(ThreadContext context, IRubyObject obj, Block block)

public static IRubyObject
create(IRubyObject klass, IRubyObject[] args, Block block)
Deprecated since 10.0.

public static IRubyObject
create(ThreadContext context, IRubyObject klass, IRubyObject[] args, Block block)

rb_ary_s_create

public static RubyClass
createArrayClass(ThreadContext context, RubyClass Object, RubyModule Enumerable)

public IRubyObject
cycle(ThreadContext context, Block block)

rb_ary_cycle

public IRubyObject
cycle(ThreadContext context, IRubyObject arg, Block block)

rb_ary_cycle

private IRubyObject
cycleCommon(ThreadContext context, long n, Block block)

private static IRubyObject
cycleSize(ThreadContext context, RubyArray<T extends IRubyObject> self, IRubyObject[] args)

A cycle size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public IRubyObject
public IRubyObject
delete(ThreadContext context, IRubyObject item, Block block)

rb_ary_delete

public IRubyObject
delete_at(int pos)
Deprecated since 10.0.

public IRubyObject
delete_at(ThreadContext context, int pos)

rb_ary_delete_at

public IRubyObject
delete_at(IRubyObject obj)
Deprecated since 10.0.

public IRubyObject
delete_at(ThreadContext context, IRubyObject obj)

rb_ary_delete_at_m

public IRubyObject
delete_if(ThreadContext context, Block block)

public IRubyObject
deleteIf(ThreadContext context, Block block)

rb_ary_delete_if

private static IRubyObject
descendingFactorial(ThreadContext context, long from, long howMany)

public IRubyObject
detectCommon(ThreadContext context, IRubyObject ifnone, Block block)

public IRubyObject
difference(ThreadContext context, IRubyObject[] args)

rb_ary_difference_multi

public IRubyObject
dig(ThreadContext context, IRubyObject arg0)

public IRubyObject
public IRubyObject
public IRubyObject
dig(ThreadContext context, IRubyObject[] args)

public IRubyObject
drop(ThreadContext context, IRubyObject n)

rb_ary_take

public IRubyObject
drop_while(ThreadContext context, Block block)

rb_ary_take_while

public IRubyObject

Returns:

A new RubyArray sharing the original backing store.
dup
()

Overrides org.jruby.RubyBasicObject.dup.

Implements org.jruby.runtime.builtin.IRubyObject.dup.

Overridden dup for fast-path logic.

protected RubyArray<T extends IRubyObject>
dupImpl(Ruby runtime, RubyClass metaClass)

public IRubyObject
each(ThreadContext context, Block block)

mri: rb_ary_each

public IRubyObject
each_index(ThreadContext context, Block block)

public IRubyObject
public IRubyObject
eachIndex(ThreadContext context, Block block)

rb_ary_each_index

public IRubyObject
eachSlice(ThreadContext context, int size, Block block)

private final IRubyObject
elt(long offset)

rb_ary_elt

public T
eltInternal(int offset)

public T
eltInternalSet(int offset, T item)

public T
eltOk(long offset)

public T
eltSetOk(long offset, T value)

public T
eltSetOk(int offset, T value)

public IRubyObject
empty_p()
Deprecated since 10.0.

public IRubyObject
empty_p(ThreadContext context)

rb_ary_empty_p

public void
ensureCapacity(int
the desired minimum capacity of the internal array
minCapacity
)
Deprecated

Increases the capacity of this Array, if necessary.

public final IRubyObject
entry(long offset)

rb_ary_entry

public final IRubyObject
entry(int offset)

public IRubyObject
eql(ThreadContext context, IRubyObject obj)

rb_ary_eql

public boolean
equals(Object
the object to be compared for equality with this list
other
)

Overrides org.jruby.RubyObject.equals.

Implements java.util.List.equals.

Compares the specified object with this list for equality.

public IRubyObject
fetch(ThreadContext context, IRubyObject[] args, Block block)
Deprecated since 9.4-. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
fetch(ThreadContext context, IRubyObject arg0, Block block)

rb_ary_fetch

public IRubyObject
fetch(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)

rb_ary_fetch

public IRubyObject
fetch_values(ThreadContext context, IRubyObject[] args, Block block)

public IRubyObject
fill(ThreadContext context, Block block)

public IRubyObject
fill(ThreadContext context, IRubyObject arg, Block block)

public IRubyObject
fill(ThreadContext context, IRubyObject arg1, IRubyObject arg2, Block block)

public IRubyObject
fill(ThreadContext context, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block block)

private int
protected IRubyObject
fillCommon(ThreadContext context, int beg, long len, IRubyObject item)

protected IRubyObject
fillCommon(ThreadContext context, int beg, long len, Block block)

private long
fillLen(ThreadContext context, long beg, IRubyObject arg)

public IRubyObject
find(ThreadContext context, IRubyObject ifnone, Block block)

public IRubyObject
find_index(ThreadContext context, Block block)

public IRubyObject
public IRubyObject
first(IRubyObject[] args)
Deprecated since 9.4-. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
first()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
first(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
protected boolean
flatten(ThreadContext context, final int level, final RubyArray<T extends IRubyObject> result)

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public RubyBoolean
frozen_p(ThreadContext context)

Overrides org.jruby.RubyBasicObject.frozen_p.

rb_ary_frozen_p

public Object
get(int
index of the element to return
index
)

Implements java.util.List.get.

Returns the element at the specified position in this list.

private int
private IRubyObject
private IRubyObject
private IRubyObject
public Class<T>
getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

public int
public final List<IRubyObject>

Returns:

a read-only copy of this list
getList
()
Deprecated since 9.4-. RubyArray implements List, use it directly

public ClassIndex
getNativeClassIndex()

Overrides org.jruby.RubyObject.getNativeClassIndex.

Implements org.jruby.runtime.marshal.CoreObjectType.getNativeClassIndex.

This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

private Long
public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

rb_ary_hash

private long
hashImpl(final ThreadContext context)

public RubyBoolean
include_p(ThreadContext context, IRubyObject item)

rb_ary_includes

public boolean
public boolean
public IRubyObject
index(ThreadContext context, IRubyObject obj)

rb_ary_index

public IRubyObject
index(ThreadContext context, IRubyObject obj, Block unused)

public IRubyObject
index(ThreadContext context, Block block)

public IRubyObject
indexes(IRubyObject[] args)
Deprecated

public IRubyObject
indexes(ThreadContext context, IRubyObject[] args)
Deprecated since 10.0.

public int
indexOf(Object
element to search for
element
)

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

public IRubyObject
initialize(ThreadContext context, IRubyObject[] args, Block block)
Deprecated since 9.4-. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
initialize(ThreadContext context, Block block)

rb_ary_initialize

public IRubyObject
initialize(ThreadContext context, IRubyObject arg0, Block block)

rb_ary_initialize

public IRubyObject
initialize(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)

rb_ary_initialize

public IRubyObject
initialize_copy(ThreadContext
the thread context
context
,
IRubyObject
the original
orig
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

rb_ary_initialize_copy

protected IRubyObject
public IRubyObject
public IRubyObject
insert(IRubyObject arg)
Deprecated since 10.0.

public IRubyObject
insert(ThreadContext context, IRubyObject arg)

rb_ary_insert

public IRubyObject
insert(IRubyObject arg1, IRubyObject arg2)
Deprecated since 10.0.

public IRubyObject
private void
insert(ThreadContext context, long pos, IRubyObject val)

public IRubyObject
insert(IRubyObject[] args)
Deprecated

public IRubyObject
insert(ThreadContext context, IRubyObject[] args)

public RubyString
protected IRubyObject
inspectAry(ThreadContext context)

inspect_ary

protected IRubyObject
internalRotate(ThreadContext context, int cnt)

protected IRubyObject
public IRubyObject
intersect_p(ThreadContext context, IRubyObject other)

MRI: rb_ary_intersect_p

public IRubyObject
public boolean
isEmpty()

Implements java.util.List.isEmpty.

Returns true if this list contains no elements.

private static boolean
isPackedArray(final int size)

private static boolean
isPackedArray(final Collection<? extends IRubyObject> collection)

public boolean
public Iterator<E>
iterator()

Implements java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

public IRubyObject
join(final ThreadContext context, IRubyObject sep)

rb_ary_join

public IRubyObject
public IRubyObject
join19(final ThreadContext context, IRubyObject sep)
Deprecated

public IRubyObject
join19(ThreadContext context)
Deprecated

private RubyString
joinAny(ThreadContext context, RubyString sep, int i, RubyString result, boolean[] first)

protected int
joinStrings(RubyString sep, int max, RubyString result)

public IRubyObject
keep_if(ThreadContext context, Block block)

public IRubyObject
last(IRubyObject[] args)
Deprecated since 9.4-. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
last()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
last(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
last(ThreadContext context, IRubyObject arg0)

rb_ary_last

public int
lastIndexOf(Object
element to search for
element
)

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

public RubyFixnum
length(ThreadContext context)

rb_ary_length

public RubyFixnum
length()
Deprecated

public ListIterator<E>
listIterator()

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

public ListIterator<E>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.

private RubyHash
makeHash(Ruby runtime)

ary_make_hash

private RubyHash
private RubyHash
makeHash(ThreadContext context, Block block)

private RubyHash
makeHash(ThreadContext context, RubyHash hash, Block block)

protected RubyArray<?>
makeShared()

rb_ary_make_shared

private RubyArray<T extends IRubyObject>
makeShared(ThreadContext context, int beg, int len, RubyClass klass)

private final RubyArray<T extends IRubyObject>
makeShared(ThreadContext context, int beg, int len, RubyArray<T extends IRubyObject> sharedArray)

private RubyArray<T extends IRubyObject>
makeSharedFirst(ThreadContext context, IRubyObject num, boolean last)

ary_shared_first

public IRubyObject
map(ThreadContext context, Block block)

public IRubyObject
map_bang(ThreadContext context, Block block)

rb_ary_collect_bang

public static void
marshalTo(RubyArray<T extends IRubyObject> array, MarshalStream output)
Deprecated for removal since 10.0.

public static void
marshalTo(ThreadContext context, RubyArray<T extends IRubyObject> array, MarshalStream output)
Deprecated for removal since 10.0.

public static void
public IRubyObject
max(ThreadContext context, Block block)

public IRubyObject
max(ThreadContext context, IRubyObject num, Block block)

private IRubyObject
public IRubyObject
min(ThreadContext context, Block block)

public IRubyObject
min(ThreadContext context, IRubyObject num, Block block)

public IRubyObject
minmax(ThreadContext context, Block block)

private IRubyObject
protected void
modify()
Deprecated since 10.0.

protected void
modify(ThreadContext context)

rb_ary_modify

protected final void
modifyCheck()
Deprecated since 10.0.

protected final void
modifyCheck(ThreadContext context)

rb_ary_modify_check

public static final RubyArray<T extends IRubyObject>
newArray(final Ruby runtime, final long len)
Deprecated since 10.0. Use Create#allocArray(ThreadContext, int) instead

Create array with specific allocated size

public static final RubyArray<?>
newArray(final Ruby runtime, final int len)

public static final RubyArray<?>
newArray(ThreadContext context, final int len)

public static final RubyArray<?>
newArray(final Ruby runtime)
Deprecated since 10.0.

public static final RubyArray<?>
newArray(ThreadContext context)

rb_ary_new

public static RubyArray<?>
newArray(Ruby runtime, IRubyObject obj)

public static RubyArray<?>
newArray(Ruby runtime, IRubyObject car, IRubyObject cdr)

rb_assoc_new

public static RubyArray<?>
newArray(Ruby runtime, IRubyObject first, IRubyObject second, IRubyObject third)

public static RubyArray<?>
newArray(Ruby runtime, IRubyObject first, IRubyObject second, IRubyObject third, IRubyObject fourth)

public static RubyArray<?>
newArray(Ruby runtime, IRubyObject[] args)

rb_ary_new4, rb_ary_new3

public static RubyArray<?>
newArray(Ruby runtime, Collection<? extends IRubyObject> collection)

public static RubyArray<?>
newArray(Ruby runtime, List<? extends IRubyObject> list)

public static final RubyArray<?>
newArrayLight(final Ruby runtime, final long len)
Deprecated since 10.0.

public static final RubyArray<?>
newArrayLight(final Ruby runtime, final int len)

public static final RubyArray<?>
newArrayLight(final Ruby runtime)

rb_ary_new

public static RubyArray<?>
public static RubyArray<?>
public static RubyArray<?>
public static RubyArray<?>
public static RubyArray<?>
newArrayLight(Ruby runtime, IRubyObject... objs)

public static RubyArray<T extends IRubyObject>
newArrayMayCopy(Ruby runtime, IRubyObject... args)

public static RubyArray<T extends IRubyObject>
newArrayMayCopy(Ruby runtime, IRubyObject[] args, int start)

public static RubyArray<T extends IRubyObject>

Returns:

an array referencing the given elements
newArrayMayCopy
(Ruby
the runtime
runtime
,
IRubyObject[]
the args
args
,
int
start index
start
,
int
number of elements
length
)

Construct a new RubyArray given the specified range of elements in the source array.

public static RubyArray<T extends IRubyObject>
newArrayNoCopy(Ruby runtime, IRubyObject... args)

public static RubyArray<T extends IRubyObject>
newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin)

public static RubyArray<T extends IRubyObject>
newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin, int length)

public static RubyArray<T extends IRubyObject>
public static RubyArray<T extends IRubyObject>
newBlankArray(Ruby runtime, int size)
Deprecated since 10.0.

public static RubyArray<T extends IRubyObject>

Returns:

a RubyArray shaped for the given size
newBlankArray
(ThreadContext
the current thread context
context
,
int
the size
size
)

Construct the most efficient array shape for the given size.

pack-priv static RubyArray<T extends IRubyObject>
newBlankArrayInternal(Ruby runtime, int size)

pack-priv static RubyArray<T extends IRubyObject>
newBlankArrayInternal(Ruby runtime, RubyClass metaClass, int size)

public static RubyArray<?>
public static RubyArray<?>
newEmptyArray(Ruby runtime, RubyClass klass)

public static RubyArray<?>
newSharedArray(RubyClass arrayClass, IRubyObject[] shared)

public IRubyObject
nitems(ThreadContext context)

rb_ary_nitems

public IRubyObject
nitems()
Deprecated

public IRubyObject
none_p(ThreadContext context, Block block)

public IRubyObject
none_p(ThreadContext context, IRubyObject arg, Block block)

private IRubyObject
public IRubyObject
public IRubyObject
one_p(ThreadContext context, Block block)

public IRubyObject
one_p(ThreadContext context, IRubyObject arg, Block block)

private IRubyObject
public IRubyObject
public IRubyObject
op_and(IRubyObject other)
Deprecated since 10.0.

public IRubyObject
op_and(ThreadContext context, IRubyObject other)

MRI: rb_ary_and

public IRubyObject
public IRubyObject
op_diff(IRubyObject other)
Deprecated since 10.0.

public IRubyObject
op_diff(ThreadContext context, IRubyObject other)

rb_ary_diff

public IRubyObject
public IRubyObject
op_or(IRubyObject other)
Deprecated since 10.0.

public IRubyObject
op_or(ThreadContext context, IRubyObject other)

rb_ary_or

public IRubyObject
op_plus(IRubyObject obj)
Deprecated since 10.0.

public IRubyObject
op_plus(ThreadContext context, IRubyObject obj)

rb_ary_plus

public IRubyObject
op_times(ThreadContext context, IRubyObject times)

rb_ary_times

private static final int
optimizedCmp(ThreadContext context, IRubyObject a, IRubyObject b, int token, CachingCallSite op_cmp, CallSite op_gt, CallSite op_lt)

public RubyString
public RubyString
pack(ThreadContext context, IRubyObject obj, IRubyObject maybeOpts)

private static RubyArray<?>
packedArray(final Ruby runtime, final IRubyObject[] args)

private static RubyArray<?>
packedArray(final Ruby runtime, final List<? extends IRubyObject> args)

public IRubyObject
permutation(ThreadContext context, IRubyObject num, Block block)

rb_ary_permutation

public IRubyObject
private IRubyObject
permutationCommon(ThreadContext context, int r, boolean repeat, Block block)

private static IRubyObject
permutationSize(ThreadContext context, RubyArray<T extends IRubyObject> self, IRubyObject[] args)

A permutation size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

private static void
permute(ThreadContext context, int n, int r, int[] p, boolean[] used, RubyArray<T extends IRubyObject> values, Block block)

public IRubyObject
pop(ThreadContext context)

rb_ary_pop

public IRubyObject
public IRubyObject
product(ThreadContext context, IRubyObject[] args)

rb_ary_product

public IRubyObject
product(ThreadContext context, IRubyObject[] args, Block block)

public RubyArray<T extends IRubyObject>
push(IRubyObject item)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
public RubyArray<?>
push(IRubyObject[] items)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
push(ThreadContext context, IRubyObject[] items)

public RubyArray<?>
push_m(IRubyObject[] items)
Deprecated

rb_ary_push_m - instance method push

private static long
randUpto(ThreadContext context, IRubyObject randgen, int max)

public IRubyObject
rassoc(ThreadContext context, IRubyObject value)

rb_ary_rassoc

public IRubyObject
rb_clear()
Deprecated since 10.0.

public IRubyObject
rb_clear(ThreadContext context)

rb_ary_clear

public IRubyObject
rbCollect(ThreadContext context, Block block)

rb_ary_collect

private static void
rcombinate(ThreadContext context, int n, int r, int[] p, RubyArray<T extends IRubyObject> values, Block block)

private void
realloc(ThreadContext context, int newLength, int valuesLength)

private void
recursiveJoin(final ThreadContext context, final IRubyObject outValue, final RubyString sep, final RubyString result, final RubyArray<T extends IRubyObject> ary, final boolean[] first)

public IRubyObject
reject(ThreadContext context, Block block)

public IRubyObject
public IRubyObject
rejectBang(ThreadContext context, Block block)

public final IRubyObject
rejectCommon(ThreadContext context, Block block)

rb_ary_reject_bang

public boolean
remove(Object
element to be removed from this list, if present
element
)

Implements java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).

public Object
remove(int
the index of the element to be removed
index
)

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).

public boolean
removeAll(Collection<E>
collection containing elements to be removed from this list
c
)

Implements java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

public IRubyObject
public IRubyObject
private static IRubyObject
repeatedCombinationSize(ThreadContext context, RubyArray<T extends IRubyObject> self, IRubyObject[] args)

A repeated combination size method suitable for method reference implementation of SizeFnsize(ThreadContext, RubyArray, IRubyObject[]).

private static IRubyObject
repeatedPermutationSize(ThreadContext context, RubyArray<T extends IRubyObject> self, IRubyObject[] args)

A repeated permutation size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public IRubyObject
replace(IRubyObject orig)
Deprecated since 10.0.

public IRubyObject
replace(ThreadContext context, IRubyObject orig)

rb_ary_replace

private void
public boolean
retainAll(Collection<E>
collection containing elements to be retained in this list
c
)

Implements java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).

public IRubyObject
reverse()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
reverse_bang()
Deprecated since 10.0.

public IRubyObject
reverse_bang(ThreadContext context)

rb_ary_reverse_bang

public IRubyObject
public IRubyObject
reverseEach(ThreadContext context, Block block)

rb_ary_reverse_each

public IRubyObject
rindex(ThreadContext context, IRubyObject obj)

rb_ary_rindex

public IRubyObject
rindex(ThreadContext context, IRubyObject obj, Block unused)

public IRubyObject
rindex(ThreadContext context, Block block)

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
private static int
rotateCount(int cnt, int len)

private static void
rpermute(ThreadContext context, int n, int r, int[] p, RubyArray<T extends IRubyObject> values, Block block)

public Stream<IRubyObject>
rubyStream()

Returns a stream of each IRubyObject

private static void
safeArrayCopy(ThreadContext context, IRubyObject[] source, int sourceStart, IRubyObject[] target, int targetStart, int length)

private static IRubyObject
safeArrayRef(ThreadContext context, IRubyObject[] values, int i)

private static IRubyObject
safeArrayRefCondSet(ThreadContext context, IRubyObject[] values, int i, boolean doSet, IRubyObject value)

private static IRubyObject
safeArrayRefSet(ThreadContext context, IRubyObject[] values, int i, IRubyObject value)

protected static IRubyObject
safeArraySet(ThreadContext context, IRubyObject[] values, int i, IRubyObject value)

protected RubyArray<T extends IRubyObject>
public IRubyObject
public IRubyObject
sample(ThreadContext context, IRubyObject sampleOrOpts)

public IRubyObject
public IRubyObject
sample(ThreadContext context, IRubyObject[] args)
Deprecated

private IRubyObject
sampleCommon(ThreadContext context, IRubyObject randgen)

Common sample logic when no sample size was specified.

private IRubyObject
sampleCommon(ThreadContext context, IRubyObject sample, IRubyObject randgen)

Common sample logic when a sample size was specified.

public IRubyObject
select(ThreadContext context, Block block)

public IRubyObject
private void
selectBangEnsure(ThreadContext context, int i1, int i2)

public IRubyObject
selectCommon(ThreadContext context, Block block)

rb_ary_select

public Object
set(int
index of the element to replace
index
,
Object
element to be stored at the specified position
element
)

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

private void
public IRubyObject
shift(ThreadContext context)

rb_ary_shift

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
shuffle(ThreadContext context, IRubyObject[] args)
Deprecated

public IRubyObject
public IRubyObject
public IRubyObject
shuffle_bang(ThreadContext context, IRubyObject[] args)
Deprecated

private IRubyObject
private static JavaSites.ArraySites
sites(ThreadContext context)

Hides org.jruby.RubyObject.sites.

Retrieve the call sites for this class.

protected static IRubyObject
size(ThreadContext context, RubyArray<T extends IRubyObject> self, IRubyObject[] args)

A size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public int
size()

Implements java.util.List.size.

Returns the number of elements in this list.

public IRubyObject
slice_bang(IRubyObject[] args)
Deprecated since 9.4-. Use the versions with zero, one, or two args.

Variable arity version for compatibility.

public IRubyObject
slice_bang(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
slice_bang(ThreadContext context, IRubyObject arg0)

rb_ary_slice_bang

public IRubyObject
slice_bang(IRubyObject arg0, IRubyObject arg1)
Deprecated since 10.0.

public IRubyObject
slice_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1)

rb_ary_slice_bang

private IRubyObject
slice_internal(ThreadContext context, int pos, int len)

public RubyArray<T extends IRubyObject>
sort(ThreadContext context, Block block)

rb_ary_sort

public IRubyObject
sort_bang(ThreadContext context, Block block)

rb_ary_sort_bang

public IRubyObject
sort_by_bang(ThreadContext context, Block block)

rb_ary_sort_by_bang

protected IRubyObject
sortInternal(final ThreadContext context, final boolean honorOverride)

protected IRubyObject
sortInternal(final ThreadContext context, final Block block)

private void
splice(ThreadContext context, int beg, int len, IRubyObject rpl)

private void
splice(ThreadContext context, int beg, int len, final RubyArray<T extends IRubyObject> rplArr, final int rlen)

rb_ary_splice

private final void
spliceOne(ThreadContext context, long beg, IRubyObject rpl)

rb_ary_splice

private void
spliceRealloc(ThreadContext context, int length, int valuesLength)

public IRubyObject
store(long index, IRubyObject value)

public IRubyObject

Returns:

the value set
store
(ThreadContext
the current thread context
context
,
long
the offset to store the value
index
,
IRubyObject
the value to be stored
value
)

Store an element at the specified index or throw if the index is invalid.

protected void
storeInternal(ThreadContext context, final int index, final IRubyObject value)

private void
storeRealloc(ThreadContext context, final int index, final int valuesLength)

private static void
strJoin(RubyString result, RubyString val, boolean[] first)

public List<E>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

public IRubyObject
subseq(long beg, long len)

rb_ary_subseq

public IRubyObject
subseq(RubyClass metaClass, long beg, long len, boolean light)

public IRubyObject
subseq_step(ThreadContext context, RubyArithmeticSequence arg0)

rb_ary_subseq_step

public IRubyObject
subseqLight(long beg, long len)

rb_ary_subseq

public IRubyObject
sum(final ThreadContext context, final Block block)

public IRubyObject
sum(final ThreadContext context, IRubyObject init, final Block block)

public IRubyObject
sumCommon(final ThreadContext context, IRubyObject init, final Block block)

public IRubyObject
take(ThreadContext context, IRubyObject n)

rb_ary_take

public IRubyObject
take_while(ThreadContext context, Block block)

rb_ary_take_while

public RubyArray<T extends IRubyObject>
to_a(ThreadContext context)

Overrides org.jruby.RubyBasicObject.to_a.

rb_ary_to_a

public RubyArray<T extends IRubyObject>
to_a()

Overrides org.jruby.RubyBasicObject.to_a.

Deprecated

public IRubyObject
to_ary()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
to_h(ThreadContext context)
Deprecated

public IRubyObject
to_h(ThreadContext context, Block block)

public RubyString
to_s(ThreadContext context)

Overrides org.jruby.RubyBasicObject.to_s.

rb_ary_to_s

public Object[]
toArray()

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

public Object[]
toArray(final Object[]
the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
arg
)

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

public <T> T
toJava(Class<T>
The target type to which the object should be converted.
target
)

Overrides org.jruby.RubyBasicObject.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Convert the object to the specified Java class, if possible.

public IRubyObject[]

Returns:

""
toJavaArray
()
Deprecated since 10.0. Use RubyArray#toJavaArray(ThreadContext) instead.

public IRubyObject[]

Returns:

a Java array with exactly the size and contents of this RubyArray's elements
toJavaArray
(ThreadContext context)

Return a Java array copy of the elements contained in this Array.

public IRubyObject[]

Returns:

a Java array with exactly the size and contents of this RubyArray's elements, possibly the actual underlying array.
toJavaArrayMaybeUnsafe
()

Return a Java array of the elements contained in this array, possibly a new array object.

public IRubyObject[]

Returns:

The underlying Java array for this RubyArray, or a copy if that array is shared.
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.

public RubyArray<T extends IRubyObject>
transpose()
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
transpose(ThreadContext context)

rb_ary_transpose

public static IRubyObject
public IRubyObject
union(ThreadContext context, IRubyObject[] args)

rb_ary_union_multi

private void
unionInternal(ThreadContext context, RubyArray<T extends IRubyObject>... args)

rb_ary_union

public IRubyObject
uniq(ThreadContext context)

rb_ary_uniq

public IRubyObject
uniq(ThreadContext context, Block block)

public IRubyObject
uniq_bang(ThreadContext context)

rb_ary_uniq_bang

public IRubyObject
uniq_bang(ThreadContext context, Block block)

public static RubyArray<T extends IRubyObject>
unmarshalFrom(UnmarshalStream input)
Deprecated for removal since 10.0.

public static RubyArray<T extends IRubyObject>
protected void
unpack(ThreadContext context)

Overridden by specialized arrays to fall back to IRubyObject[].

public IRubyObject

Returns:

""
unshift
()
Deprecated Use RubyArray#unshift(ThreadContext) instead

public IRubyObject
public IRubyObject
unshift(IRubyObject item)
Deprecated since 10.0.

public IRubyObject
unshift(ThreadContext context, IRubyObject item)

rb_ary_unshift

public IRubyObject
unshift(IRubyObject[] items)
Deprecated since 10.0.

public IRubyObject
unshift(ThreadContext context, IRubyObject[] items)

private void
unshiftRealloc(ThreadContext context, int valuesLength)

public IRubyObject
values_at(IRubyObject[] args)
Deprecated since 10.0.

public IRubyObject
values_at(ThreadContext context, IRubyObject[] args)

rb_values_at

private static void
yieldValues(ThreadContext context, int r, int[] p, int pStart, RubyArray<T extends IRubyObject> values, Block block)

public IRubyObject
zip(ThreadContext context, IRubyObject[] args, Block block)

rb_ary_zip

private IRubyObject
Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalfinishObjectClasshashCodeinspectop_eqqputsspecificEvaltoRubyStringtoString