Go to the source code of this file.
|
typedef struct internal_multiset * | multiset |
|
|
multiset | multiset_init (size_t key_size, int(*comparator)(const void *const one, const void *const two)) |
|
size_t | multiset_size (multiset me) |
|
bk_bool | multiset_is_empty (multiset me) |
|
bk_err | multiset_put (multiset me, void *key) |
|
size_t | multiset_count (multiset me, void *key) |
|
bk_bool | multiset_contains (multiset me, void *key) |
|
bk_bool | multiset_remove (multiset me, void *key) |
|
bk_bool | multiset_remove_all (multiset me, void *key) |
|
void * | multiset_first (multiset me) |
|
void * | multiset_last (multiset me) |
|
void * | multiset_lower (multiset me, void *key) |
|
void * | multiset_higher (multiset me, void *key) |
|
void * | multiset_floor (multiset me, void *key) |
|
void * | multiset_ceiling (multiset me, void *key) |
|
void | multiset_clear (multiset me) |
|
multiset | multiset_destroy (multiset me) |
|
◆ multiset
typedef struct internal_multiset* multiset |
The multiset data structure, which is a collection of key-value pairs, sorted by keys, keys are unique
◆ multiset_ceiling()
void* multiset_ceiling |
( |
multiset |
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 multi-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
◆ multiset_clear()
Clears the keys from the multiset.
- Parameters
-
◆ multiset_contains()
Determines if the multi-set contains the specified key. The pointer to the key being passed in should point to the key type which this multi-set holds. For example, if this multi-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 multi-set to check for the key |
key | the key to check |
- Returns
- BK_TRUE if the multiset contained the key, otherwise BK_FALSE
◆ multiset_count()
size_t multiset_count |
( |
multiset |
me, |
|
|
void *const |
key |
|
) |
| |
Determines the count of a specific key in the multi-set. The pointer to the key being passed in should point to the key type which this multi-set holds. For example, if this multi-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 multi-set to check for the count |
key | the key to check |
- Returns
- the count of a specific key in the multi-set
◆ multiset_destroy()
Frees the multi-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 multi-set to free from memory |
- Returns
- NULL
◆ multiset_first()
Returns the first (lowest) key in this multi-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 multi-set to get the key from |
- Returns
- the lowest key in this multi-set, or NULL if it is empty
◆ multiset_floor()
void* multiset_floor |
( |
multiset |
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 multi-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
◆ multiset_higher()
void* multiset_higher |
( |
multiset |
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 multi-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
◆ multiset_init()
multiset multiset_init |
( |
size_t |
key_size, |
|
|
int(*)(const void *const one, const void *const two) |
comparator |
|
) |
| |
◆ multiset_is_empty()
Determines whether or not the multi-set is empty.
- Parameters
-
- Returns
- BK_TRUE if the multi-set is empty, otherwise BK_FALSE
◆ multiset_last()
Returns the last (highest) key in this multi-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 multi-set to get the key from |
- Returns
- the highest key in this multi-set, or NULL if it is empty
◆ multiset_lower()
void* multiset_lower |
( |
multiset |
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 multi-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
◆ multiset_put()
Adds a key to the multi-set. The pointer to the key being passed in should point to the key type which this multi-set holds. For example, if this multi-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 multi-set to add to |
key | the key to add |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ multiset_remove()
Removes a key from the multi-set if it contains it. The pointer to the key being passed in should point to the key type which this multi-set holds. For example, if this multi-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 multi-set to remove a key from |
key | the key to remove |
- Returns
- BK_TRUE if the multi-set contained the key, otherwise BK_FALSE
◆ multiset_remove_all()
Removes all the occurrences of a specified key in the multi-set. The pointer to the key being passed in should point to the key type which this multi-set holds. For example, if this multi-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 multi-set to remove a key from |
key | the key to remove |
- Returns
- BK_TRUE if the multi-set contained the key, otherwise BK_FALSE
◆ multiset_size()
Gets the size of the multi-set.
- Parameters
-
- Returns
- the size of the multi-set