Go to the source code of this file.
|
typedef struct internal_set * | set |
|
◆ set
typedef struct internal_set* set |
The set data structure, which is a collection of unique keys, sorted by keys.
◆ set_ceiling()
void* set_ceiling |
( |
set |
me, |
|
|
void *const |
key |
|
) |
| |
Returns the key which is the ceiling of the comparison key. Meaning that the the lowest key which is higher or equal to the key used for comparison is returned.
- Parameters
-
me | the set to get the ceiling key from |
key | the key to use for comparison |
- Returns
- the key which is the ceiling, or NULL if it does not exist
◆ set_clear()
Clears the keys from the set.
- Parameters
-
◆ set_contains()
Determines if the set contains the specified key. The pointer to the key being passed in should point to the key type which this set holds. For example, if this set holds key integers, the key pointer should be a pointer to an integer. Since the key is being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the set to check for the key |
key | the key to check |
- Returns
- BK_TRUE if the set contained the key, otherwise BK_FALSE
◆ set_destroy()
Frees the set memory. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
- Parameters
-
me | the set to free from memory |
- Returns
- NULL
◆ set_first()
void* set_first |
( |
set |
me | ) |
|
Returns the first (lowest) key in this set. The returned key is a pointer to the internally stored key, which should not be modified. Modifying it results in undefined behaviour.
- Parameters
-
me | the set to get the key from |
- Returns
- the lowest key in this set, or NULL if it is empty
◆ set_floor()
void* set_floor |
( |
set |
me, |
|
|
void *const |
key |
|
) |
| |
Returns the key which is the floor of the comparison key. Meaning that the the highest key which is lower or equal to the key used for comparison is returned.
- Parameters
-
me | the set to get the floor key from |
key | the key to use for comparison |
- Returns
- the key which is the floor, or NULL if it does not exist
◆ set_higher()
void* set_higher |
( |
set |
me, |
|
|
void *const |
key |
|
) |
| |
Returns the key which is strictly higher than the comparison key. Meaning that the lowest key which is higher than the key used for comparison is returned.
- Parameters
-
me | the set to get the higher key from |
key | the key to use for comparison |
- Returns
- the key which is strictly higher, or NULL if it does not exist
◆ set_init()
set set_init |
( |
size_t |
key_size, |
|
|
int(*)(const void *const one, const void *const two) |
comparator |
|
) |
| |
◆ set_is_empty()
Determines whether or not the set is empty.
- Parameters
-
- Returns
- BK_TRUE if the set is empty, otherwise BK_FALSE
◆ set_last()
Returns the last (highest) key in this set. The returned key is a pointer to the internally stored key, which should not be modified. Modifying it results in undefined behaviour.
- Parameters
-
me | the set to get the key from |
- Returns
- the highest key in this set, or NULL if it is empty
◆ set_lower()
void* set_lower |
( |
set |
me, |
|
|
void *const |
key |
|
) |
| |
Returns the key which is strictly lower than the comparison key. Meaning that the highest key which is lower than the key used for comparison is returned.
- Parameters
-
me | the set to get the lower key from |
key | the key to use for comparison |
- Returns
- the key which is strictly lower, or NULL if it does not exist
◆ set_put()
Adds a key to the set if the set does not already contain it. The pointer to the key being passed in should point to the key type which this set holds. For example, if this set holds key integers, the key pointer should be a pointer to an integer. Since the key is being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the set to add to |
key | the key to add |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ set_remove()
Removes the key from the set if it contains it. The pointer to the key being passed in should point to the key type which this set holds. For example, if this set holds key integers, the key pointer should be a pointer to an integer. Since the key is being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the set to remove an key from |
key | the key to remove |
- Returns
- BK_TRUE if the set contained the key, otherwise BK_FALSE
◆ set_size()
size_t set_size |
( |
set |
me | ) |
|
Gets the size of the set.
- Parameters
-
- Returns
- the size of the set