Ruby 3.5.0dev (2025-07-15 revision 87944065838321018bf99fc61dbec84ccad2576c)
|
Public APIs related to rb_cSet. More...
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Go to the source code of this file.
Functions | |
void | rb_set_foreach (VALUE set, int(*func)(VALUE element, VALUE arg), VALUE arg) |
Iterates over a set. | |
VALUE | rb_set_new (void) |
Creates a new, empty set object. | |
VALUE | rb_set_new_capa (size_t capa) |
Identical to rb_set_new(), except it additionally specifies how many elements it is expected to contain. | |
bool | rb_set_lookup (VALUE set, VALUE element) |
Whether the set contains the given element. | |
bool | rb_set_add (VALUE set, VALUE element) |
Adds element to set. | |
VALUE | rb_set_clear (VALUE set) |
Removes all entries from set. | |
bool | rb_set_delete (VALUE set, VALUE element) |
Removes the element from from set. | |
size_t | rb_set_size (VALUE set) |
Returns the number of elements in the set. | |
Public APIs related to rb_cSet.
RBIMPL
or rbimpl
are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will. __VA_ARGS__
is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98. Definition in file set.h.
Adds element to set.
[in] | set | Target set table to modify. |
[in] | element | Arbitrary Ruby object. |
rb_eFrozenError | `set` is frozen. |
element
is in set
. Definition at line 1943 of file set.c.
Referenced by rb_set_add().
Removes all entries from set.
[out] | set | Target to clear. |
rb_eFrozenError | `set`is frozen. |
set
set
has no elements. Definition at line 1949 of file set.c.
Referenced by rb_set_clear().
Removes the element from from set.
[in] | set | Target set to modify. |
[in] | element | Key to delete. |
true | if element was already in set, false otherwise |
set
does not have element
as an element. Definition at line 1955 of file set.c.
Referenced by rb_set_delete().
Iterates over a set.
Calls func with each element of the set and the argument given. func should return ST_CONTINUE, ST_STOP, or ST_DELETE.
[in] | set | An instance of rb_cSet to iterate over. |
[in] | func | Callback function to yield. |
[in] | arg | Passed as-is to func . |
rb_eRuntimeError | `set` was tampered during iterating. |
Definition at line 1919 of file set.c.
Referenced by rb_set_foreach().
Whether the set contains the given element.
[in] | set | Set to look into. |
[in] | element | Set element to look for. |
Definition at line 1937 of file set.c.
Referenced by rb_set_lookup().
VALUE rb_set_new | ( | void | ) |
Creates a new, empty set object.
Definition at line 1925 of file set.c.
Referenced by rb_set_new().
VALUE rb_set_new_capa | ( | size_t | capa | ) |
Identical to rb_set_new(), except it additionally specifies how many elements it is expected to contain.
This way you can create a set that is large enough for your need. For large sets, it means it won't need to be reallocated much, improving performance.
[in] | capa | Designed capacity of the set. |
capa
. Definition at line 1931 of file set.c.
Referenced by rb_set_new_capa().
size_t rb_set_size | ( | VALUE | set | ) |
Returns the number of elements in the set.
[in] | set | A set object. |
Definition at line 1961 of file set.c.
Referenced by rb_set_size().