Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
unordered_multiset.h File Reference
#include "_bk_defines.h"
Include dependency graph for unordered_multiset.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct internal_unordered_multiset * unordered_multiset
 

Functions

unordered_multiset unordered_multiset_init (size_t key_size, unsigned long(*hash)(const void *const key), int(*comparator)(const void *const one, const void *const two))
 
bk_err unordered_multiset_rehash (unordered_multiset me)
 
size_t unordered_multiset_size (unordered_multiset me)
 
bk_bool unordered_multiset_is_empty (unordered_multiset me)
 
bk_err unordered_multiset_put (unordered_multiset me, void *key)
 
size_t unordered_multiset_count (unordered_multiset me, void *key)
 
bk_bool unordered_multiset_contains (unordered_multiset me, void *key)
 
bk_bool unordered_multiset_remove (unordered_multiset me, void *key)
 
bk_bool unordered_multiset_remove_all (unordered_multiset me, void *key)
 
bk_err unordered_multiset_clear (unordered_multiset me)
 
unordered_multiset unordered_multiset_destroy (unordered_multiset me)
 

Typedef Documentation

◆ unordered_multiset

typedef struct internal_unordered_multiset* unordered_multiset

The unordered_multiset data structure, which is a collection of keys, hashed by keys.

Function Documentation

◆ unordered_multiset_clear()

bk_err unordered_multiset_clear ( unordered_multiset  me)

Clears the keys from the unordered multi-set.

Parameters
methe unordered multi-set to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multiset_contains()

bk_bool unordered_multiset_contains ( unordered_multiset  me,
void *const  key 
)

Determines if the unordered multi-set contains the specified element. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this unordered 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
methe unordered multi-set to check for the key
keythe key to check
Returns
BK_TRUE if the unordered multi-set contained the key, otherwise BK_FALSE

◆ unordered_multiset_count()

size_t unordered_multiset_count ( unordered_multiset  me,
void *const  key 
)

Determines the count of a specific key in the unordered multi-set. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this unordered 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
methe unordered multi-set to check for the count
keythe element to check
Returns
the count of a specific key in the unordered multi-set

◆ unordered_multiset_destroy()

unordered_multiset unordered_multiset_destroy ( unordered_multiset  me)

Frees the unordered 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
methe unordered multi-set to free from memory
Returns
NULL

◆ unordered_multiset_init()

unordered_multiset unordered_multiset_init ( size_t  key_size,
unsigned long(*)(const void *const key)  hash,
int(*)(const void *const one, const void *const two)  comparator 
)

◆ unordered_multiset_is_empty()

bk_bool unordered_multiset_is_empty ( unordered_multiset  me)

Determines whether or not the unordered multi-set is empty.

Parameters
methe unordered multi-set to check
Returns
BK_TRUE if the unordered multi-set is empty, otherwise BK_FALSE

◆ unordered_multiset_put()

bk_err unordered_multiset_put ( unordered_multiset  me,
void *const  key 
)

Adds an element to the unordered multi-set. The pointer to the key being passed in should point to the key type which this unordered 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
methe unordered multi-set to add to
keythe element to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multiset_rehash()

bk_err unordered_multiset_rehash ( unordered_multiset  me)

Rehashes all the keys in the unordered multi-set. Used when storing references and changing the keys. This should rarely be used.

Parameters
methe unordered multi-set to rehash
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multiset_remove()

bk_bool unordered_multiset_remove ( unordered_multiset  me,
void *const  key 
)

Removes a key from the unordered multi-set if it contains it. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this unordered 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
methe unordered multi-set to remove a key from
keythe key to remove
Returns
BK_TRUE if the unordered multi-set contained the key, otherwise BK_FALSE

◆ unordered_multiset_remove_all()

bk_bool unordered_multiset_remove_all ( unordered_multiset  me,
void *const  key 
)

Removes all the keys specified by the key from an unordered multi-set if it contains the 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
methe unordered multi-set to remove a key from
keythe key to remove
Returns
BK_TRUE if the unordered multi-set contained the key, otherwise BK_FALSE

◆ unordered_multiset_size()

size_t unordered_multiset_size ( unordered_multiset  me)

Gets the size of the unordered multi-set.

Parameters
methe unordered multi-set to check
Returns
the size of the unordered multi-set