Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
array.h
Go to the documentation of this file.
1 #ifndef RBIMPL_INTERN_ARRAY_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_INTERN_ARRAY_H
28 #include "ruby/internal/value.h"
29 
31 
32 /* array.c */
33 
43 void rb_mem_clear(VALUE *buf, long len)
45  ;
46 
56 VALUE rb_assoc_new(VALUE car, VALUE cdr);
57 
71 
77 VALUE rb_ary_new(void);
78 
90 
98 VALUE rb_ary_new_from_args(long n, ...);
99 
107 VALUE rb_ary_new_from_values(long n, const VALUE *elts);
108 
117 #define rb_ary_tmp_new rb_ary_hidden_new
118 
134 void rb_ary_free(VALUE ary);
135 
145 void rb_ary_modify(VALUE ary);
146 
155 
173 
200 VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary);
201 
214 VALUE rb_ary_subseq(VALUE ary, long beg, long len);
215 
231 void rb_ary_store(VALUE ary, long key, VALUE val);
232 
244 VALUE rb_ary_dup(VALUE ary);
245 
255 
268 
278 VALUE rb_ary_to_s(VALUE ary);
279 
291 VALUE rb_ary_cat(VALUE ary, const VALUE *train, long len);
292 
302 VALUE rb_ary_push(VALUE ary, VALUE elem);
303 
316 VALUE rb_ary_pop(VALUE ary);
317 
334 
346 VALUE rb_ary_unshift(VALUE ary, VALUE elem);
347 
359 VALUE rb_ary_entry(VALUE ary, long off);
360 
370 VALUE rb_ary_each(VALUE ary);
371 
385 VALUE rb_ary_join(VALUE ary, VALUE sep);
386 
397 
410 VALUE rb_ary_rotate(VALUE ary, long rot);
411 
423 VALUE rb_ary_sort(VALUE ary);
424 
438 
460 VALUE rb_ary_delete(VALUE ary, VALUE elem);
461 
475 VALUE rb_ary_delete_at(VALUE ary, long pos);
476 
486 
504 VALUE rb_ary_plus(VALUE lhs, VALUE rhs);
505 
517 VALUE rb_ary_concat(VALUE lhs, VALUE rhs);
518 
552 VALUE rb_ary_assoc(VALUE alist, VALUE key);
553 
564 VALUE rb_ary_rassoc(VALUE alist, VALUE key);
565 
582 VALUE rb_ary_includes(VALUE ary, VALUE elem);
583 
594 VALUE rb_ary_cmp(VALUE lhs, VALUE rhs);
595 
607 VALUE rb_ary_replace(VALUE copy, VALUE orig);
608 
636 VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE (*func)(VALUE obj, long oidx));
637 
655 VALUE rb_ary_resize(VALUE ary, long len);
656 
657 #define rb_ary_new2 rb_ary_new_capa
658 #define rb_ary_new3 rb_ary_new_from_args
659 #define rb_ary_new4 rb_ary_new_from_values
662 
663 #endif /* RBIMPL_INTERN_ARRAY_H */
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
VALUE rb_ary_rotate(VALUE ary, long rot)
Destructively rotates the passed array in-place to towards its end.
Definition: array.c:3202
VALUE rb_ary_new_from_values(long n, const VALUE *elts)
Identical to rb_ary_new_from_args(), except how objects are passed.
Definition: array.c:780
VALUE rb_ary_cmp(VALUE lhs, VALUE rhs)
Recursively compares each elements of the two arrays one-by-one using <=>.
Definition: array.c:5455
VALUE rb_ary_rassoc(VALUE alist, VALUE key)
Identical to rb_ary_assoc(), except it scans the passed array from the opposite direction.
Definition: array.c:5184
VALUE rb_ary_concat(VALUE lhs, VALUE rhs)
Destructively appends the contents of latter into the end of former.
Definition: array.c:5068
VALUE rb_ary_assoc(VALUE alist, VALUE key)
Looks up the passed key, assuming the passed array is an alist.
Definition: array.c:5152
VALUE rb_ary_reverse(VALUE ary)
Destructively reverses the passed array in-place.
Definition: array.c:3113
VALUE rb_ary_shared_with_p(VALUE lhs, VALUE rhs)
Queries if the passed two arrays share the same backend storage.
Definition: array.c:663
VALUE rb_ary_shift(VALUE ary)
Destructively deletes an element from the beginning of the passed array and returns what was deleted.
Definition: array.c:1490
VALUE rb_ary_sort(VALUE ary)
Creates a copy of the passed array, whose elements are sorted according to their <=> result.
Definition: array.c:3481
VALUE rb_ary_resurrect(VALUE ary)
I guess there is no use case of this function in extension libraries, but this is a routine identical...
Definition: array.c:2784
VALUE rb_ary_dup(VALUE ary)
Duplicates an array.
Definition: array.c:2771
VALUE rb_ary_includes(VALUE ary, VALUE elem)
Queries if the passed array has the passed entry.
Definition: array.c:5367
VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary)
Queries element(s) of an array.
Definition: array.c:1889
VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE(*func)(VALUE obj, long oidx))
This was a generalisation of Array#values_at, Struct#values_at, and MatchData#values_at.
void rb_ary_free(VALUE ary)
Destroys the given array for no reason.
Definition: array.c:869
VALUE rb_ary_each(VALUE ary)
Iteratively yields each element of the passed array to the implicitly passed block if any.
Definition: array.c:2635
VALUE rb_ary_delete_at(VALUE ary, long pos)
Destructively removes an element which resides at the specific index of the passed array.
Definition: array.c:4102
VALUE rb_ary_unshift(VALUE ary, VALUE elem)
Destructively prepends the passed item at the beginning of the passed array.
Definition: array.c:1713
VALUE rb_ary_plus(VALUE lhs, VALUE rhs)
Creates a new array, concatenating the former to the latter.
Definition: array.c:5005
VALUE rb_ary_cat(VALUE ary, const VALUE *train, long len)
Destructively appends multiple elements at the end of the array.
Definition: array.c:1391
void rb_ary_modify(VALUE ary)
Declares that the array is about to be modified.
Definition: array.c:570
VALUE rb_ary_replace(VALUE copy, VALUE orig)
Replaces the contents of the former object with the contents of the latter.
Definition: array.c:4674
VALUE rb_check_array_type(VALUE obj)
Try converting an object to its array representation using its to_ary method, if any.
Definition: array.c:1008
VALUE rb_ary_to_ary(VALUE obj)
Force converts an object to an array.
Definition: array.c:2191
VALUE rb_ary_new(void)
Allocates a new, empty array.
Definition: array.c:741
VALUE rb_ary_new_capa(long capa)
Identical to rb_ary_new(), except it additionally specifies how many rooms of objects it should alloc...
Definition: array.c:735
VALUE rb_ary_resize(VALUE ary, long len)
Expands or shrinks the passed array to the passed length.
Definition: array.c:2290
VALUE rb_ary_pop(VALUE ary)
Destructively deletes an element from the end of the passed array and returns what was deleted.
Definition: array.c:1425
VALUE rb_ary_hidden_new(long capa)
Allocates a hidden (no class) empty array.
Definition: array.c:853
VALUE rb_ary_clear(VALUE ary)
Destructively removes everything form an array.
Definition: array.c:4729
VALUE rb_ary_subseq(VALUE ary, long beg, long len)
Obtains a part of the passed array.
Definition: array.c:1759
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
Definition: array.c:1378
VALUE rb_ary_freeze(VALUE obj)
Freeze an array, preventing further modifications.
Definition: array.c:642
VALUE rb_ary_to_s(VALUE ary)
Converts an array into a human-readable string.
Definition: array.c:3007
VALUE rb_ary_new_from_args(long n,...)
Constructs an array from the passed objects.
Definition: array.c:747
VALUE rb_ary_entry(VALUE ary, long off)
Queries an element of an array.
Definition: array.c:1731
VALUE rb_ary_sort_bang(VALUE ary)
Destructively sorts the passed array in-place, according to each elements' <=> result.
Definition: array.c:3388
VALUE rb_assoc_new(VALUE car, VALUE cdr)
Identical to rb_ary_new_from_values(), except it expects exactly two parameters.
Definition: array.c:995
void rb_mem_clear(VALUE *buf, long len)
Fills the memory region with a series of RUBY_Qnil.
Definition: array.c:288
VALUE rb_ary_delete(VALUE ary, VALUE elem)
Destructively removes elements from the passed array, so that there would be no elements inside that ...
Definition: array.c:4048
VALUE rb_ary_join(VALUE ary, VALUE sep)
Recursively stringises the elements of the passed array, flattens that result, then joins the sequenc...
Definition: array.c:2885
void rb_ary_store(VALUE ary, long key, VALUE val)
Destructively stores the passed value to the passed array's passed index.
Definition: array.c:1201
int capa
Designed capacity of the buffer.
Definition: io.h:11
int off
Offset inside of ptr.
Definition: io.h:5
RBIMPL_ATTR_PURE() int rb_io_read_pending(rb_io_t *fptr)
Queries if the passed IO has any pending reads.
int len
Length of the buffer.
Definition: io.h:8
Defines RBIMPL_ATTR_NOALIAS.
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition: noalias.h:62
Defines RBIMPL_ATTR_NOEXCEPT.
#define RBIMPL_ATTR_NOEXCEPT(_)
Wraps (or simulates) C++11 noexcept
Definition: noexcept.h:73
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:27
Defines RBIMPL_ATTR_PURE.
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40