Ruby: include/ruby/internal/intern/array.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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
23#include "ruby/internal/attr/noalias.h"
24#include "ruby/internal/attr/noexcept.h"
25#include "ruby/internal/attr/nonnull.h"
26#include "ruby/internal/attr/pure.h"
27#include "ruby/internal/dllexport.h"
28#include "ruby/internal/value.h"
29
30 RBIMPL_SYMBOL_EXPORT_BEGIN()
31
32/* array.c */
33
34 RBIMPL_ATTR_NONNULL(())
35 RBIMPL_ATTR_NOALIAS()
43void rb_mem_clear(VALUE *buf, long len)
44 RBIMPL_ATTR_NOEXCEPT(true)
45 ;
46
56 VALUE rb_assoc_new(VALUE car, VALUE cdr);
57
70 VALUE rb_check_array_type(VALUE obj);
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
116 VALUE rb_ary_hidden_new(long capa);
117#define rb_ary_tmp_new rb_ary_hidden_new
118
134void rb_ary_free(VALUE ary);
135
145void rb_ary_modify(VALUE ary);
146
148 VALUE rb_ary_freeze(VALUE obj);
149
150 RBIMPL_ATTR_PURE()
166 VALUE rb_ary_shared_with_p(VALUE lhs, VALUE rhs);
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
225void rb_ary_store(VALUE ary, long key, VALUE val);
226
238 VALUE rb_ary_dup(VALUE ary);
239
248 VALUE rb_ary_resurrect(VALUE ary);
249
261 VALUE rb_ary_to_ary(VALUE obj);
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
327 VALUE rb_ary_shift(VALUE ary);
328
340 VALUE rb_ary_unshift(VALUE ary, VALUE elem);
341
342 RBIMPL_ATTR_PURE()
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
390 VALUE rb_ary_reverse(VALUE ary);
391
404 VALUE rb_ary_rotate(VALUE ary, long rot);
405
417 VALUE rb_ary_sort(VALUE ary);
418
431 VALUE rb_ary_sort_bang(VALUE ary);
432
454 VALUE rb_ary_delete(VALUE ary, VALUE elem);
455
469 VALUE rb_ary_delete_at(VALUE ary, long pos);
470
479 VALUE rb_ary_clear(VALUE ary);
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
655 RBIMPL_SYMBOL_EXPORT_END()
656
657#endif /* RBIMPL_INTERN_ARRAY_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
rb_ary_rotate
VALUE rb_ary_rotate(VALUE ary, long rot)
Destructively rotates the passed array in-place to towards its end.
Definition array.c:3325
rb_ary_new_from_values
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:904
rb_ary_cmp
VALUE rb_ary_cmp(VALUE lhs, VALUE rhs)
Recursively compares each elements of the two arrays one-by-one using <=>.
Definition array.c:5503
rb_ary_rassoc
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:5258
rb_ary_concat
VALUE rb_ary_concat(VALUE lhs, VALUE rhs)
Destructively appends the contents of latter into the end of former.
Definition array.c:5145
rb_ary_assoc
VALUE rb_ary_assoc(VALUE alist, VALUE key)
Looks up the passed key, assuming the passed array is an alist.
Definition array.c:5228
rb_ary_reverse
VALUE rb_ary_reverse(VALUE ary)
Destructively reverses the passed array in-place.
Definition array.c:3238
rb_ary_shared_with_p
VALUE rb_ary_shared_with_p(VALUE lhs, VALUE rhs)
Queries if the passed two arrays share the same backend storage.
Definition array.c:783
rb_ary_shift
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:1600
rb_ary_sort
VALUE rb_ary_sort(VALUE ary)
Creates a copy of the passed array, whose elements are sorted according to their <=> result.
Definition array.c:3673
rb_ary_resurrect
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:2907
rb_ary_dup
VALUE rb_ary_dup(VALUE ary)
Duplicates an array.
Definition array.c:2894
rb_ary_includes
VALUE rb_ary_includes(VALUE ary, VALUE elem)
Queries if the passed array has the passed entry.
Definition array.c:5422
rb_ary_aref
VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary)
Queries element(s) of an array.
Definition array.c:1977
rb_get_values_at
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.
Definition array.c:3874
rb_ary_free
void rb_ary_free(VALUE ary)
Destroys the given array for no reason.
Definition array.c:998
rb_ary_each
VALUE rb_ary_each(VALUE ary)
Iteratively yields each element of the passed array to the implicitly passed block if any.
Definition array.c:2734
rb_ary_delete_at
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:4231
rb_ary_unshift
VALUE rb_ary_unshift(VALUE ary, VALUE elem)
Destructively prepends the passed item at the beginning of the passed array.
Definition array.c:1818
rb_ary_plus
VALUE rb_ary_plus(VALUE lhs, VALUE rhs)
Creates a new array, concatenating the former to the latter.
Definition array.c:5085
rb_ary_cat
VALUE rb_ary_cat(VALUE ary, const VALUE *train, long len)
Destructively appends multiple elements at the end of the array.
Definition array.c:1496
rb_ary_modify
void rb_ary_modify(VALUE ary)
Declares that the array is about to be modified.
Definition array.c:701
rb_ary_replace
VALUE rb_ary_replace(VALUE copy, VALUE orig)
Replaces the contents of the former object with the contents of the latter.
Definition array.c:4735
rb_check_array_type
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:1129
rb_ary_to_ary
VALUE rb_ary_to_ary(VALUE obj)
Force converts an object to an array.
Definition array.c:2326
rb_ary_new
VALUE rb_ary_new(void)
Allocates a new, empty array.
Definition array.c:865
rb_ary_new_capa
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:859
rb_ary_resize
VALUE rb_ary_resize(VALUE ary, long len)
Expands or shrinks the passed array to the passed length.
Definition array.c:2420
rb_ary_pop
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:1534
rb_ary_hidden_new
VALUE rb_ary_hidden_new(long capa)
Allocates a hidden (no class) empty array.
Definition array.c:981
rb_ary_clear
VALUE rb_ary_clear(VALUE ary)
Destructively removes everything form an array.
Definition array.c:4791
rb_ary_subseq
VALUE rb_ary_subseq(VALUE ary, long beg, long len)
Obtains a part of the passed array.
Definition array.c:1864
rb_ary_push
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
Definition array.c:1483
rb_ary_freeze
VALUE rb_ary_freeze(VALUE obj)
Just another name of rb_obj_freeze.
Definition array.c:770
rb_ary_to_s
VALUE rb_ary_to_s(VALUE ary)
Converts an array into a human-readable string.
Definition array.c:3128
rb_ary_entry
VALUE rb_ary_entry(VALUE ary, long off)
Queries an element of an array.
Definition array.c:1836
rb_ary_sort_bang
VALUE rb_ary_sort_bang(VALUE ary)
Destructively sorts the passed array in-place, according to each elements' <=> result.
Definition array.c:3572
rb_assoc_new
VALUE rb_assoc_new(VALUE car, VALUE cdr)
Identical to rb_ary_new_from_values(), except it expects exactly two parameters.
Definition array.c:1116
rb_mem_clear
void rb_mem_clear(VALUE *buf, long len)
Fills the memory region with a series of RUBY_Qnil.
Definition array.c:331
rb_ary_delete
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:4177
rb_ary_join
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:3008
rb_ary_store
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:1313
noalias.h
Defines RBIMPL_ATTR_NOALIAS.
RBIMPL_ATTR_NOALIAS
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition noalias.h:66
noexcept.h
Defines RBIMPL_ATTR_NOEXCEPT.
RBIMPL_ATTR_NOEXCEPT
#define RBIMPL_ATTR_NOEXCEPT(_)
Wraps (or simulates) C++11 noexcept
Definition noexcept.h:85
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40