Next: Language-visible functions, Previous: Queue functions, Up: Run-time library functions [Contents][Index]
Because unordered collections of data are a widely applicable construct, the run-time library provides support for sets. A set contains zero or more keys, each of which must be unique within the set. Furthermore, each key can be associated with a data value. Sets are currently implemented in the coNCePTuaL run-time library as hash tables.
Allocate and initialize a set object and return a pointer to it.
Each element in the set maps a keybytes-byte key to a
valuebytes-byte value. The numelts parameter
is an estimate of the maximum number of elements in the set.
ncptl_set_init()
returns a
pointer to the set.
Given a set and a pointer to a key, return a pointer to the
associated value or NULL
if the key is not found in
the set.
Insert a key into a set and associate a value with it. ncptl_set_insert()
copies
both key and value so stack-allocated keys
and values are acceptable inputs. The run-time library aborts with
an error message if the key is already in the set.
Execute function userfunc for every
<key:value> pair in a set.
userfunc must take two void *
values as
input: a pointer to a key and a pointer to a value. The order in
which keys and values are passed to the function is
unspecified.
Remove a key and its associated value from a set. The run-time library aborts with an error message if the key is not found in the set.
Empty a set, freeing the memory that had been allocated for its
contents. The set itself can continue to be used and should be
deallocated with ncptl_free()
(see
Memory-allocation functions) when no longer needed.
Return the number of <key:value> pairs in set set.
Next: Language-visible functions, Previous: Queue functions, Up: Run-time library functions [Contents][Index]