|
Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)
|
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.
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. |
Definition at line 1965 of file set.c.
Referenced by rb_set_add().
Removes all entries from set.
| [out] | set | Target to clear. |
| rb_eFrozenError | `set`is frozen. |
Definition at line 1971 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 |
Definition at line 1977 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 1941 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 1959 of file set.c.
Referenced by rb_set_lookup().
| VALUE rb_set_new | ( | void | ) |
| 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. |
Definition at line 1953 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 1983 of file set.c.
Referenced by rb_set_size().