Ruby  3.1.4p223 (2023-03-30 revision HEAD)
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 
89 VALUE rb_ary_new_capa(long capa);
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 VALUE rb_ary_tmp_new(long capa);
118 
134 void rb_ary_free(VALUE ary);
135 
145 void rb_ary_modify(VALUE ary);
146 
149 
167 
194 VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary);
195 
208 VALUE rb_ary_subseq(VALUE ary, long beg, long len);
209 
225 void rb_ary_store(VALUE ary, long key, VALUE val);
226 
238 VALUE rb_ary_dup(VALUE ary);
239 
249 
262 
272 VALUE rb_ary_to_s(VALUE ary);
273 
285 VALUE rb_ary_cat(VALUE ary, const VALUE *train, long len);
286 
296 VALUE rb_ary_push(VALUE ary, VALUE elem);
297 
310 VALUE rb_ary_pop(VALUE ary);
311 
328 
340 VALUE rb_ary_unshift(VALUE ary, VALUE elem);
341 
353 VALUE rb_ary_entry(VALUE ary, long off);
354 
364 VALUE rb_ary_each(VALUE ary);
365 
379 VALUE rb_ary_join(VALUE ary, VALUE sep);
380 
391 
404 VALUE rb_ary_rotate(VALUE ary, long rot);
405 
417 VALUE rb_ary_sort(VALUE ary);
418 
432 
454 VALUE rb_ary_delete(VALUE ary, VALUE elem);
455 
469 VALUE rb_ary_delete_at(VALUE ary, long pos);
470 
480 
498 VALUE rb_ary_plus(VALUE lhs, VALUE rhs);
499 
511 VALUE rb_ary_concat(VALUE lhs, VALUE rhs);
512 
546 VALUE rb_ary_assoc(VALUE alist, VALUE key);
547 
558 VALUE rb_ary_rassoc(VALUE alist, VALUE key);
559 
576 VALUE rb_ary_includes(VALUE ary, VALUE elem);
577 
588 VALUE rb_ary_cmp(VALUE lhs, VALUE rhs);
589 
601 VALUE rb_ary_replace(VALUE copy, VALUE orig);
602 
630 VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE (*func)(VALUE obj, long oidx));
631 
649 VALUE rb_ary_resize(VALUE ary, long len);
650 
651 #define rb_ary_new2 rb_ary_new_capa
652 #define rb_ary_new3 rb_ary_new_from_args
653 #define rb_ary_new4 rb_ary_new_from_values
656 
657 #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:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
VALUE rb_ary_rotate(VALUE ary, long rot)
Destructively rotates the passed array in-place to towards its end.
Definition: array.c:3078
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:789
VALUE rb_ary_cmp(VALUE lhs, VALUE rhs)
Recursively compares each elements of the two arrays one-by-one using <=>.
Definition: array.c:5129
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:4898
VALUE rb_ary_concat(VALUE lhs, VALUE rhs)
Destructively appends the contents of latter into the end of former.
Definition: array.c:4790
VALUE rb_ary_assoc(VALUE alist, VALUE key)
Looks up the passed key, assuming the passed array is an alist.
Definition: array.c:4869
VALUE rb_ary_reverse(VALUE ary)
Destructively reverses the passed array in-place.
Definition: array.c:2995
VALUE rb_ary_shared_with_p(VALUE lhs, VALUE rhs)
Queries if the passed two arrays share the same backend storage.
Definition: array.c:688
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:1420
VALUE rb_ary_sort(VALUE ary)
Creates a copy of the passed array, whose elements are sorted according to their <=> result.
Definition: array.c:3406
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:2676
VALUE rb_ary_dup(VALUE ary)
Duplicates an array.
Definition: array.c:2663
VALUE rb_ary_includes(VALUE ary, VALUE elem)
Queries if the passed array has the passed entry.
Definition: array.c:5057
VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary)
Queries element(s) of an array.
Definition: array.c:1809
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:865
VALUE rb_ary_each(VALUE ary)
Iteratively yields each element of the passed array to the implicitly passed block if any.
Definition: array.c:2516
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:3941
VALUE rb_ary_unshift(VALUE ary, VALUE elem)
Destructively prepends the passed item at the beginning of the passed array.
Definition: array.c:1661
VALUE rb_ary_plus(VALUE lhs, VALUE rhs)
Creates a new array, concatenating the former to the latter.
Definition: array.c:4731
VALUE rb_ary_cat(VALUE ary, const VALUE *train, long len)
Destructively appends multiple elements at the end of the array.
Definition: array.c:1321
void rb_ary_modify(VALUE ary)
Declares that the array is about to be modified.
Definition: array.c:607
VALUE rb_ary_replace(VALUE copy, VALUE orig)
Replaces the contents of the former object with the contents of the latter.
Definition: array.c:4415
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:989
VALUE rb_ary_to_ary(VALUE obj)
Force converts an object to an array.
Definition: array.c:2140
VALUE rb_ary_new(void)
Allocates a new, empty array.
Definition: array.c:750
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:744
VALUE rb_ary_resize(VALUE ary, long len)
Expands or shrinks the passed array to the passed length.
Definition: array.c:2234
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:1357
VALUE rb_ary_tmp_new(long capa)
Allocates a "temporary" array.
Definition: array.c:847
VALUE rb_ary_clear(VALUE ary)
Destructively removes everything form an array.
Definition: array.c:4465
VALUE rb_ary_subseq(VALUE ary, long beg, long len)
Obtains a part of the passed array.
Definition: array.c:1707
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
Definition: array.c:1308
VALUE rb_ary_freeze(VALUE obj)
Just another name of rb_obj_freeze.
Definition: array.c:675
VALUE rb_ary_to_s(VALUE ary)
Converts an array into a human-readable string.
Definition: array.c:2891
VALUE rb_ary_new_from_args(long n,...)
Constructs an array from the passed objects.
Definition: array.c:756
VALUE rb_ary_entry(VALUE ary, long off)
Queries an element of an array.
Definition: array.c:1679
VALUE rb_ary_sort_bang(VALUE ary)
Destructively sorts the passed array in-place, according to each elements' <=> result.
Definition: array.c:3307
VALUE rb_assoc_new(VALUE car, VALUE cdr)
Identical to rb_ary_new_from_values(), except it expects exactly two parameters.
Definition: array.c:976
void rb_mem_clear(VALUE *buf, long len)
Fills the memory region with a series of RUBY_Qnil.
Definition: array.c:260
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:3887
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:2777
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:1148
RBIMPL_ATTR_PURE() int rb_io_read_pending(rb_io_t *fptr)
Queries if the passed IO has any pending reads.
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