Name

set_insert

Synopsis

int set_insert(Set *set, const void *data);

Return Value

0 if inserting the member is successful, 1 if the member is already in the set, or -1 otherwise.

Description

Inserts a member into the set specified by set. The new member contains a pointer to data, so the memory referenced by data should remain valid as long as the member remains in the set. It is the responsibility of the caller to manage the storage associated with data.

Complexity

O (n), where n is the number of members in the set.

Get Mastering Algorithms with C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.