Header: mruby/array.h
Overview
Array class
Function Summary collapse
-
void mrb_ary_modify(mrb_state*, struct RArray*)
-
mrb_value mrb_ary_new_capa(mrb_state*, mrb_int)
-
mrb_value mrb_ary_new(mrb_state *)
Initializes a new array.
-
mrb_value mrb_ary_new_from_values(mrb_state *, mrb_int, const mrb_value *)
Initializes a new array with initial values.
-
mrb_value mrb_assoc_new(mrb_state *, mrb_value, mrb_value)
Initializes a new array with two initial values.
-
void mrb_ary_concat(mrb_state *, mrb_value, mrb_value)
Concatenate two arrays.
-
mrb_value mrb_ary_splat(mrb_state *, mrb_value)
Create an array from the input.
-
void mrb_ary_push(mrb_state *, mrb_value, mrb_value)
Pushes value into array.
-
mrb_value mrb_ary_pop(mrb_state *, mrb_value)
Pops the last element from the array.
-
mrb_value mrb_ary_ref(mrb_state *, mrb_value, mrb_int)
Returns a reference to an element of the array on the given index.
-
void mrb_ary_set(mrb_state *, mrb_value, mrb_int, mrb_value)
Sets a value on an array at the given index.
-
void mrb_ary_replace(mrb_state *, mrb_value, mrb_value)
Replace the array with another array.
-
mrb_value mrb_ensure_array_type(mrb_state *, mrb_value)
-
mrb_value mrb_check_array_type(mrb_state *, mrb_value)
-
mrb_value mrb_ary_unshift(mrb_state *, mrb_value, mrb_value)
Unshift an element into the array.
-
mrb_value mrb_ary_entry(mrb_value, mrb_int)
Get nth element in the array.
-
mrb_value mrb_ary_splice(mrb_state *, mrb_value, mrb_int, mrb_int, mrb_value)
Replace subsequence of an array.
-
mrb_value mrb_ary_shift(mrb_state *, mrb_value)
Shifts the first element from the array.
-
mrb_value mrb_ary_clear(mrb_state *, mrb_value)
Removes all elements from the array.
-
mrb_value mrb_ary_join(mrb_state *, mrb_value, mrb_value)
Join the array elements together in a string.
-
mrb_value mrb_ary_resize(mrb_state *, mrb_value, mrb_int)
Update the capacity of the array.
Define Summary
- #define MRUBY_ARRAY_H
- #define MRB_ARY_EMBED_LEN_MAX
- #define mrb_ary_ptr
- #define mrb_ary_value
- #define RARRAY
- #define MRB_ARY_EMBED_MASK
- #define ARY_EMBED_P
- #define ARY_UNSET_EMBED_FLAG
- #define ARY_EMBED_LEN
- #define ARY_SET_EMBED_LEN
- #define ARY_EMBED_PTR
- #define ARY_LEN
- #define ARY_PTR
- #define RARRAY_LEN
- #define RARRAY_PTR
- #define ARY_SET_LEN
- #define ARY_CAPA
- #define MRB_ARY_SHARED
- #define ARY_SHARED_P
- #define ARY_SET_SHARED_FLAG
- #define ARY_UNSET_SHARED_FLAG
Function Details
void mrb_ary_modify(mrb_state* , struct RArray* )
mrb_value mrb_ary_new_capa(mrb_state* , mrb_int )
mrb_value mrb_ary_new(mrb_state * mrb)
Initializes a new array.
Equivalent to:
Array.new
mrb_value mrb_ary_new_from_values(mrb_state * mrb, mrb_int size, const mrb_value * vals)
Initializes a new array with initial values
Equivalent to:
Array[value1, value2, ...]
mrb_value mrb_assoc_new(mrb_state * mrb, mrb_value car, mrb_value cdr)
Initializes a new array with two initial values
Equivalent to:
Array[car, cdr]
void mrb_ary_concat(mrb_state * mrb, mrb_value self, mrb_value other)
Concatenate two arrays. The target array will be modified
Equivalent to: ary.concat(other)
mrb_value mrb_ary_splat(mrb_state * mrb, mrb_value value)
Create an array from the input. It tries calling to_a on the value. If value does not respond to that, it creates a new array with just this value.
void mrb_ary_push(mrb_state * mrb, mrb_value array, mrb_value value)
Pushes value into array.
Equivalent to:
ary << value
mrb_value mrb_ary_pop(mrb_state * mrb, mrb_value ary)
Pops the last element from the array.
Equivalent to:
ary.pop
mrb_value mrb_ary_ref(mrb_state * mrb, mrb_value ary, mrb_int n)
Returns a reference to an element of the array on the given index.
Equivalent to:
ary[n]
void mrb_ary_set(mrb_state * mrb, mrb_value ary, mrb_int n, mrb_value val)
Sets a value on an array at the given index
Equivalent to:
ary[n] = val
void mrb_ary_replace(mrb_state * mrb, mrb_value self, mrb_value other)
Replace the array with another array
Equivalent to:
ary.replace(other)
mrb_value mrb_ensure_array_type(mrb_state * mrb, mrb_value self)
mrb_value mrb_check_array_type(mrb_state * mrb, mrb_value self)
mrb_value mrb_ary_unshift(mrb_state * mrb, mrb_value self, mrb_value item)
Unshift an element into the array
Equivalent to:
ary.unshift(item)
mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset)
Get nth element in the array
Equivalent to:
ary[offset]
mrb_value mrb_ary_splice(mrb_state * mrb, mrb_value self, mrb_int head, mrb_int len, mrb_value rpl)
Replace subsequence of an array.
Equivalent to:
ary.shift
mrb_value mrb_ary_shift(mrb_state * mrb, mrb_value self)
Shifts the first element from the array.
Equivalent to:
ary.shift
mrb_value mrb_ary_clear(mrb_state * mrb, mrb_value self)
Removes all elements from the array
Equivalent to:
ary.clear
mrb_value mrb_ary_join(mrb_state * mrb, mrb_value ary, mrb_value sep)
Join the array elements together in a string
Equivalent to:
ary.join(sep="")
mrb_value mrb_ary_resize(mrb_state * mrb, mrb_value ary, mrb_int new_len)
Update the capacity of the array