Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

array.c File Reference

#include "ruby.h"
#include "util.h"
#include "st.h"
#include <stdarg.h>

Go to the source code of this file.

Data Structures

struct  ary_sort_data
struct  inspect_arg

Defines

#define ARY_DEFAULT_SIZE   16
#define ARY_TMPLOCK   FL_USER1
#define va_init_list(a, b)   va_start(a,b)

Functions

void rb_mem_clear (VALUE *mem, long size)
void memfill (VALUE *mem, long size, VALUE val)
void rb_ary_modify_check (VALUE ary)
void rb_ary_modify (VALUE ary)
VALUE rb_ary_freeze (VALUE ary)
VALUE rb_ary_frozen_p (VALUE ary)
VALUE ary_alloc (VALUE)
VALUE ary_new (VALUE klass, long len)
VALUE rb_ary_new2 (long len)
VALUE rb_ary_new ()
VALUE rb_ary_new3 (long n,...)
VALUE rb_ary_new4 (long n, const VALUE *elts)
VALUE rb_assoc_new (VALUE car, VALUE cdr)
VALUE to_ary (VALUE ary)
VALUE rb_check_array_type (VALUE ary)
VALUE rb_ary_replace (VALUE, VALUE)
VALUE rb_ary_initialize (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_s_create (int argc, VALUE *argv, VALUE klass)
void rb_ary_store (VALUE ary, long idx, VALUE val)
VALUE rb_ary_push (VALUE ary, VALUE item)
VALUE rb_ary_push_m (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_pop (VALUE ary)
VALUE ary_make_shared (VALUE ary)
VALUE rb_ary_shift (VALUE ary)
VALUE rb_ary_unshift (VALUE ary, VALUE item)
VALUE rb_ary_unshift_m (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_elt (VALUE ary, long offset)
VALUE rb_ary_entry (VALUE ary, long offset)
VALUE rb_ary_subseq (VALUE ary, long beg, long len)
VALUE rb_ary_aref (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_at (VALUE ary, VALUE pos)
VALUE rb_ary_first (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_last (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_fetch (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_index (VALUE ary, VALUE val)
VALUE rb_ary_rindex (VALUE ary, VALUE val)
VALUE rb_ary_indexes (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_to_ary (VALUE obj)
void rb_ary_splice (VALUE ary, long beg, long len, VALUE rpl)
VALUE rb_ary_aset (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_insert (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_each (VALUE ary)
VALUE rb_ary_each_index (VALUE ary)
VALUE rb_ary_reverse_each (VALUE ary)
VALUE rb_ary_length (VALUE ary)
VALUE rb_ary_empty_p (VALUE ary)
VALUE rb_ary_dup (VALUE ary)
VALUE inspect_join (VALUE ary, VALUE *arg)
VALUE rb_ary_join (VALUE ary, VALUE sep)
VALUE rb_ary_join_m (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_to_s (VALUE ary)
VALUE inspect_call (struct inspect_arg *arg)
VALUE get_inspect_tbl (int create)
VALUE inspect_ensure (VALUE obj)
VALUE rb_protect_inspect (func, VALUE obj, VALUE arg)
VALUE rb_inspecting_p (VALUE obj)
VALUE inspect_ary (VALUE ary)
VALUE rb_ary_inspect (VALUE ary)
VALUE rb_ary_to_a (VALUE ary)
VALUE rb_ary_to_ary_m (VALUE ary)
VALUE rb_ary_reverse (VALUE ary)
VALUE rb_ary_reverse_bang (VALUE ary)
VALUE rb_ary_reverse_m (VALUE ary)
void ary_sort_check (struct ary_sort_data *data)
int sort_1 (VALUE *a, VALUE *b, struct ary_sort_data *data)
int sort_2 (VALUE *ap, VALUE *bp, struct ary_sort_data *data)
VALUE sort_internal (VALUE ary)
VALUE sort_unlock (VALUE ary)
VALUE rb_ary_sort_bang (VALUE ary)
VALUE rb_ary_sort (VALUE ary)
VALUE rb_ary_collect (VALUE ary)
VALUE rb_ary_collect_bang (VALUE ary)
VALUE rb_values_at (VALUE(*func)(VALUE, long olen, int argc, VALUE *argv, func)
VALUE rb_ary_values_at (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_select (VALUE ary)
VALUE rb_ary_delete (VALUE ary, VALUE item)
VALUE rb_ary_delete_at (VALUE ary, long pos)
VALUE rb_ary_delete_at_m (VALUE ary, VALUE pos)
VALUE rb_ary_slice_bang (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_reject_bang (VALUE ary)
VALUE rb_ary_reject (VALUE ary)
VALUE rb_ary_delete_if (VALUE ary)
VALUE rb_ary_zip (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_transpose (VALUE ary)
VALUE rb_ary_clear (VALUE ary)
VALUE rb_ary_fill (int argc, VALUE *argv, VALUE ary)
VALUE rb_ary_plus (VALUE x, VALUE y)
VALUE rb_ary_concat (VALUE x, VALUE y)
VALUE rb_ary_times (VALUE ary, VALUE times)
VALUE rb_ary_assoc (VALUE ary, VALUE key)
VALUE rb_ary_rassoc (VALUE ary, VALUE value)
VALUE rb_ary_equal (VALUE ary1, VALUE ary2)
VALUE rb_ary_eql (VALUE ary1, VALUE ary2)
VALUE rb_ary_hash (VALUE ary)
VALUE rb_ary_includes (VALUE ary, VALUE item)
VALUE rb_ary_cmp (VALUE ary1, VALUE ary2)
VALUE ary_make_hash (VALUE ary1, VALUE ary2)
VALUE rb_ary_diff (VALUE ary1, VALUE ary2)
VALUE rb_ary_and (VALUE ary1, VALUE ary2)
VALUE rb_ary_or (VALUE ary1, VALUE ary2)
VALUE rb_ary_uniq_bang (VALUE ary)
VALUE rb_ary_uniq (VALUE ary)
VALUE rb_ary_compact_bang (VALUE ary)
VALUE rb_ary_compact (VALUE ary)
VALUE rb_ary_nitems (VALUE ary)
long flatten (VALUE ary, long idx, VALUE ary2, VALUE memo)
VALUE rb_ary_flatten_bang (VALUE ary)
VALUE rb_ary_flatten (VALUE ary)
void Init_Array ()

Variables

VALUE rb_cArray
ID id_cmp
VALUE rb_output_fs
ID inspect_key


Define Documentation

#define ARY_DEFAULT_SIZE   16
 

Definition at line 22 of file array.c.

Referenced by rb_ary_clear(), rb_ary_delete(), rb_ary_new(), rb_ary_pop(), rb_ary_store(), and rb_ary_unshift().

#define ARY_TMPLOCK   FL_USER1
 

Definition at line 45 of file array.c.

Referenced by rb_ary_frozen_p(), rb_ary_modify_check(), rb_ary_sort_bang(), and sort_unlock().

#define va_init_list a,
 )     va_start(a,b)
 

Definition at line 149 of file array.c.

Referenced by rb_ary_new3(), rb_bug(), rb_compile_error(), rb_compile_error_append(), rb_fatal(), rb_funcall(), rb_funcall_rescue(), rb_loaderror(), rb_name_error(), rb_raise(), rb_rescue2(), rb_scan_args(), rb_struct_define(), rb_struct_new(), rb_sys_warning(), rb_warn(), rb_warning(), rb_yield_values(), and warn_printf().


Function Documentation

VALUE ary_alloc VALUE   )  [static]
 

Definition at line 100 of file array.c.

References NEWOBJ, OBJSETUP, T_ARRAY, and VALUE.

Referenced by ary_new(), Init_Array(), rb_ary_s_create(), and rb_ary_subseq().

VALUE ary_make_hash VALUE  ary1,
VALUE  ary2
[static]
 

Definition at line 2608 of file array.c.

References Qtrue, RARRAY, rb_hash_aset(), rb_hash_new(), and VALUE.

Referenced by rb_ary_and(), rb_ary_diff(), rb_ary_or(), and rb_ary_uniq_bang().

VALUE ary_make_shared VALUE  ary  )  [static]
 

Definition at line 460 of file array.c.

References ELTS_SHARED, FL_SET, FL_TEST, NEWOBJ, OBJ_FREEZE, OBJSETUP, RARRAY, rb_cArray, T_ARRAY, and VALUE.

Referenced by rb_ary_replace(), rb_ary_shift(), and rb_ary_subseq().

VALUE ary_new VALUE  klass,
long  len
[static]
 

Definition at line 114 of file array.c.

References ALLOC_N, ary_alloc(), RARRAY, rb_eArgError, rb_raise(), and VALUE.

Referenced by rb_ary_new2(), rb_ary_subseq(), and rb_ary_times().

void ary_sort_check struct ary_sort_data data  )  [static]
 

Definition at line 1555 of file array.c.

References RARRAY, rb_eArgError, and rb_raise().

Referenced by sort_1(), and sort_2().

long flatten VALUE  ary,
long  idx,
VALUE  ary2,
VALUE  memo
[static]
 

Definition at line 2863 of file array.c.

References NIL_P, RARRAY, rb_ary_elt(), rb_ary_includes(), rb_ary_pop(), rb_ary_push(), rb_ary_splice(), rb_check_array_type(), rb_eArgError, rb_obj_id(), rb_raise(), and VALUE.

Referenced by rb_ary_flatten_bang().

VALUE get_inspect_tbl int  create  )  [static]
 

Definition at line 1355 of file array.c.

References inspect_key, NIL_P, Qnil, rb_ary_new(), rb_thread_current(), rb_thread_local_aref(), rb_thread_local_aset(), rb_warn(), T_ARRAY, TYPE, and VALUE.

Referenced by inspect_ensure(), rb_inspecting_p(), and rb_protect_inspect().

void Init_Array void   ) 
 

Definition at line 2965 of file array.c.

References ary_alloc(), id_cmp, inspect_key, rb_ary_and(), rb_ary_aref(), rb_ary_aset(), rb_ary_assoc(), rb_ary_at(), rb_ary_clear(), rb_ary_cmp(), rb_ary_collect(), rb_ary_collect_bang(), rb_ary_compact(), rb_ary_compact_bang(), rb_ary_concat(), rb_ary_delete(), rb_ary_delete_at_m(), rb_ary_delete_if(), rb_ary_diff(), rb_ary_each(), rb_ary_each_index(), rb_ary_empty_p(), rb_ary_eql(), rb_ary_equal(), rb_ary_fetch(), rb_ary_fill(), rb_ary_first(), rb_ary_flatten(), rb_ary_flatten_bang(), rb_ary_frozen_p(), rb_ary_hash(), rb_ary_includes(), rb_ary_index(), rb_ary_indexes(), rb_ary_initialize(), rb_ary_insert(), rb_ary_inspect(), rb_ary_join_m(), rb_ary_last(), rb_ary_length(), rb_ary_nitems(), rb_ary_or(), rb_ary_plus(), rb_ary_pop(), rb_ary_push(), rb_ary_push_m(), rb_ary_rassoc(), rb_ary_reject(), rb_ary_reject_bang(), rb_ary_replace(), rb_ary_reverse_bang(), rb_ary_reverse_each(), rb_ary_reverse_m(), rb_ary_rindex(), rb_ary_s_create(), rb_ary_select(), rb_ary_shift(), rb_ary_slice_bang(), rb_ary_sort(), rb_ary_sort_bang(), rb_ary_times(), rb_ary_to_a(), rb_ary_to_ary_m(), rb_ary_to_s(), rb_ary_transpose(), rb_ary_uniq(), rb_ary_uniq_bang(), rb_ary_unshift_m(), rb_ary_values_at(), rb_ary_zip(), rb_cArray, rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_include_module(), rb_intern(), and rb_mEnumerable.

Referenced by rb_call_inits().

VALUE inspect_ary VALUE  ary  )  [static]
 

Definition at line 1423 of file array.c.

References OBJ_TAINT, OBJ_TAINTED, Qtrue, RARRAY, rb_inspect(), rb_str_buf_append(), rb_str_buf_cat2(), rb_str_buf_new2(), and VALUE.

Referenced by rb_ary_inspect().

VALUE inspect_call struct inspect_arg arg  )  [static]
 

Definition at line 1348 of file array.c.

Referenced by rb_protect_inspect().

VALUE inspect_ensure VALUE  obj  )  [static]
 

Definition at line 1377 of file array.c.

References get_inspect_tbl(), NIL_P, Qfalse, rb_ary_pop(), and VALUE.

Referenced by rb_protect_inspect().

VALUE inspect_join VALUE  ary,
VALUE arg
[static]
 

Definition at line 1239 of file array.c.

References rb_ary_join(), and VALUE.

Referenced by rb_ary_join().

void memfill VALUE mem,
long  size,
VALUE  val
[inline, static]
 

Definition at line 35 of file array.c.

References VALUE.

Referenced by rb_ary_initialize().

VALUE rb_ary_and VALUE  ary1,
VALUE  ary2
[static]
 

Definition at line 2667 of file array.c.

References ary_make_hash(), RARRAY, rb_ary_elt(), rb_ary_new2(), rb_ary_push(), RHASH, st_data_t, st_delete(), to_ary(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_aset int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 1032 of file array.c.

References FIX2LONG, FIXNUM_P, NUM2LONG, RARRAY, rb_ary_splice(), rb_ary_store(), rb_eArgError, rb_eTypeError, rb_raise(), rb_range_beg_len(), SYMBOL_P, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_at VALUE  ary,
VALUE  pos
[static]
 

Definition at line 709 of file array.c.

References NUM2LONG, rb_ary_entry(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_collect VALUE  ary  )  [static]
 

Definition at line 1690 of file array.c.

References RARRAY, rb_ary_new2(), rb_ary_new4(), rb_ary_push(), rb_block_given_p(), rb_yield(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_collect_bang VALUE  ary  )  [static]
 

Definition at line 1722 of file array.c.

References RARRAY, rb_ary_modify(), rb_ary_store(), rb_yield(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_compact VALUE  ary  )  [static]
 

Definition at line 2827 of file array.c.

References rb_ary_compact_bang(), rb_ary_dup(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_compact_bang VALUE  ary  )  [static]
 

Definition at line 2794 of file array.c.

References end, NIL_P, Qnil, RARRAY, rb_ary_modify(), REALLOC_N, and VALUE.

Referenced by Init_Array(), and rb_ary_compact().

VALUE rb_ary_delete_at_m VALUE  ary,
VALUE  pos
[static]
 

Definition at line 1912 of file array.c.

References NUM2LONG, rb_ary_delete_at(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_delete_if VALUE  ary  )  [static]
 

Definition at line 2032 of file array.c.

References rb_ary_reject_bang(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_diff VALUE  ary1,
VALUE  ary2
[static]
 

Definition at line 2638 of file array.c.

References ary_make_hash(), RARRAY, rb_ary_elt(), rb_ary_new(), rb_ary_push(), RHASH, st_lookup(), to_ary(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_each_index VALUE  ary  )  [static]
 

Definition at line 1149 of file array.c.

References LONG2NUM, RARRAY, rb_yield(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_elt VALUE  ary,
long  offset
[inline, static]
 

Definition at line 566 of file array.c.

References Qnil, RARRAY, and VALUE.

Referenced by flatten(), rb_ary_and(), rb_ary_cmp(), rb_ary_diff(), rb_ary_entry(), rb_ary_eql(), rb_ary_equal(), rb_ary_or(), rb_ary_select(), rb_ary_transpose(), rb_ary_uniq_bang(), and rb_ary_zip().

VALUE rb_ary_empty_p VALUE  ary  )  [static]
 

Definition at line 1216 of file array.c.

References Qfalse, Qtrue, RARRAY, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_eql VALUE  ary1,
VALUE  ary2
[static]
 

Definition at line 2496 of file array.c.

References Qfalse, Qtrue, RARRAY, rb_ary_elt(), rb_eql(), T_ARRAY, TYPE, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_equal VALUE  ary1,
VALUE  ary2
[static]
 

Definition at line 2467 of file array.c.

References Qfalse, Qtrue, RARRAY, rb_ary_elt(), rb_equal(), rb_intern(), rb_respond_to(), T_ARRAY, TYPE, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_fetch int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 812 of file array.c.

References NUM2LONG, RARRAY, rb_block_given_p(), rb_eIndexError, rb_raise(), rb_scan_args(), rb_warn(), rb_yield(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_fill int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 2220 of file array.c.

References end, LONG2NUM, NIL_P, NUM2LONG, Qfalse, Qtrue, RARRAY, rb_ary_modify(), rb_block_given_p(), rb_mem_clear(), rb_range_beg_len(), rb_scan_args(), rb_yield(), REALLOC_N, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_first int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 731 of file array.c.

References NUM2LONG, Qnil, RARRAY, rb_ary_new2(), rb_ary_push(), rb_scan_args(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_flatten VALUE  ary  )  [static]
 

Definition at line 2948 of file array.c.

References rb_ary_dup(), rb_ary_flatten_bang(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_flatten_bang VALUE  ary  )  [static]
 

Definition at line 2908 of file array.c.

References flatten(), NIL_P, Qnil, RARRAY, rb_ary_new(), rb_check_array_type(), and VALUE.

Referenced by Init_Array(), and rb_ary_flatten().

VALUE rb_ary_frozen_p VALUE  ary  )  [static]
 

Definition at line 90 of file array.c.

References ARY_TMPLOCK, FL_TEST, OBJ_FROZEN, Qfalse, Qtrue, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_hash VALUE  ary  )  [static]
 

Definition at line 2520 of file array.c.

References LONG2FIX, NUM2LONG, RARRAY, rb_hash(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_index VALUE  ary,
VALUE  val
[static]
 

Definition at line 855 of file array.c.

References LONG2NUM, Qnil, RARRAY, rb_equal(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_indexes int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 908 of file array.c.

References rb_ary_aref(), rb_ary_new2(), rb_ary_push(), rb_frame_last_func(), rb_id2name(), rb_warn(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_initialize int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 265 of file array.c.

References FIXNUM_P, LONG2NUM, memfill(), NIL_P, NUM2LONG, RARRAY, rb_ary_modify(), rb_ary_replace(), rb_ary_store(), rb_block_given_p(), rb_check_array_type(), rb_eArgError, rb_raise(), rb_scan_args(), rb_warn(), rb_warning(), rb_yield(), REALLOC_N, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_insert int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 1084 of file array.c.

References NUM2LONG, RARRAY, rb_ary_new4(), rb_ary_splice(), rb_eArgError, rb_raise(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_inspect VALUE  ary  )  [static]
 

Definition at line 1450 of file array.c.

References inspect_ary(), RARRAY, rb_inspecting_p(), rb_protect_inspect(), rb_str_new2(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_join_m int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 1308 of file array.c.

References NIL_P, rb_ary_join(), rb_output_fs, rb_scan_args(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_last int  argc,
VALUE argv,
VALUE  ary
[static]
 

Definition at line 767 of file array.c.

References NUM2LONG, Qnil, RARRAY, rb_ary_new2(), rb_ary_push(), rb_scan_args(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_length VALUE  ary  )  [static]
 

Definition at line 1200 of file array.c.

References LONG2NUM, RARRAY, and VALUE.

Referenced by Init_Array().

void rb_ary_modify VALUE  ary  )  [static]
 

Definition at line 59 of file array.c.

References ALLOC_N, ELTS_SHARED, FL_TEST, FL_UNSET, MEMCPY, RARRAY, rb_ary_modify_check(), and VALUE.

Referenced by rb_ary_clear(), rb_ary_collect_bang(), rb_ary_compact_bang(), rb_ary_delete(), rb_ary_delete_at(), rb_ary_fill(), rb_ary_initialize(), rb_ary_reject_bang(), rb_ary_replace(), rb_ary_reverse(), rb_ary_sort_bang(), rb_ary_splice(), rb_ary_store(), and rb_ary_unshift().

void rb_ary_modify_check VALUE  ary  )  [inline, static]
 

Definition at line 48 of file array.c.

References ARY_TMPLOCK, FL_TEST, OBJ_FROZEN, OBJ_TAINTED, rb_error_frozen(), rb_eRuntimeError, rb_eSecurityError, rb_raise(), rb_safe_level, and VALUE.

Referenced by rb_ary_modify(), rb_ary_pop(), and rb_ary_shift().

VALUE rb_ary_nitems VALUE  ary  )  [static]
 

Definition at line 2846 of file array.c.

References LONG2NUM, NIL_P, RARRAY, and VALUE.

Referenced by Init_Array().

VALUE rb_ary_or VALUE  ary1,
VALUE  ary2
[static]
 

Definition at line 2700 of file array.c.

References ary_make_hash(), RARRAY, rb_ary_elt(), rb_ary_new2(), rb_ary_push(), RHASH, st_data_t, st_delete(), to_ary(), and VALUE.

Referenced by Init_Array().

VALUE rb_ary_push_m int  argc,