|
Ruby 4.1.0dev (2026-05-15 revision fff4b3ef2e3e309e7a84288de53c189aa3d45fed)
|
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 1972 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 1978 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 1984 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 1948 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 1966 of file set.c.
Referenced by rb_set_lookup().
| VALUE rb_set_new | ( | void | ) |
Creates a new, empty set object.
Definition at line 1954 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 1960 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 1990 of file set.c.
Referenced by rb_set_size().