Turnstone Operating System
Loading...
Searching...
No Matches
set.h File Reference

set interface More...

#include <types.h>
#include <iterator.h>

Macros

#define ___SET_H   0
 
#define set_destroy(s)   set_destroy_with_callback(s, NULL);
 

Typedefs

typedef int8_t(* set_comparator_f) (const void *item1, const void *item2)
 set comparator More...
 
typedef struct set_t set_t
 
typedef boolean_t(* set_destroy_callback_f) (void *item)
 set destroy callback More...
 

Functions

set_tset_create (set_comparator_f cmp)
 creates set More...
 
set_tset_string (void)
 creates string set More...
 
set_tset_integer (void)
 creates integer set More...
 
boolean_t set_append (set_t *s, void *value)
 append the value to the set if not exists More...
 
boolean_t set_remove (set_t *s, void *value)
 remove the value from the set More...
 
boolean_t set_exists (set_t *s, void *value)
 check value if in the the set More...
 
uint64_t set_size (set_t *s)
 returns size of the set More...
 
boolean_t set_destroy_with_callback (set_t *s, set_destroy_callback_f cb)
 destroys set More...
 
iterator_tset_create_iterator (set_t *s)
 creates set iterator More...
 

Detailed Description

set interface

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ set_destroy

#define set_destroy (   s)    set_destroy_with_callback(s, NULL);

destroys set without callback

Typedef Documentation

◆ set_comparator_f

typedef int8_t(* set_comparator_f) (const void *item1, const void *item2)

set comparator

Parameters
[in]item1item 1
[in]item2item 2

◆ set_destroy_callback_f

typedef boolean_t(* set_destroy_callback_f) (void *item)

set destroy callback

Parameters
[in]itemitem to destroy
Returns
true if free succeed

◆ set_t

typedef struct set_t set_t

set struct type

Function Documentation

◆ set_append()

boolean_t set_append ( set_t s,
void *  value 
)

append the value to the set if not exists

Parameters
[in]sthe set
[in]valueitem to append
Returns
true if succeed.

◆ set_create()

set_t * set_create ( set_comparator_f  cmp)

creates set

Parameters
[in]cmpset comparator
Returns
set or null

◆ set_create_iterator()

iterator_t * set_create_iterator ( set_t s)

creates set iterator

Parameters
[in]sthe set
Returns
iterator.

◆ set_destroy_with_callback()

boolean_t set_destroy_with_callback ( set_t s,
set_destroy_callback_f  cb 
)

destroys set

Parameters
[in]sthe set
[in]cbdestroy callback which frees items.
Returns
true if succeed.

◆ set_exists()

boolean_t set_exists ( set_t s,
void *  value 
)

check value if in the the set

Parameters
[in]sthe set
[in]valueitem to check
Returns
true if value in set.

◆ set_integer()

set_t * set_integer ( void  )

creates integer set

Returns
set of integers

◆ set_remove()

boolean_t set_remove ( set_t s,
void *  value 
)

remove the value from the set

Parameters
[in]sthe set
[in]valueitem to remove
Returns
true if succeed.

◆ set_size()

uint64_t set_size ( set_t s)

returns size of the set

Parameters
[in]sthe set
Returns
set size

◆ set_string()

set_t * set_string ( void  )

creates string set

Returns
set of strings