Set
Set
Set data structure is used for handling unique items in a list.
struct Set {
node_t *root;
queue_t *queue;
bool ordered;
int count;
int *items;
};
typedef struct Set set_t;
init_set
Parameter Name |
Type |
Description |
set_order |
bool |
Toggle if set is ordered |
set_t *init_set(bool set_order);
insert_sorted
Parameter Name |
Type |
Description |
s |
set_t |
Set instance |
id |
int |
Set ID |
string_value |
char* |
Character value |
weight |
int |
Weight value (for potential nodes) |
bool insert_sorted(set_t *s, int id, char *string_value, int weight);
insert_set_value_sorted
Parameter Name |
Type |
Description |
root |
node_t |
Root in set tree |
item |
node_t |
Item to add to tree |
node_t *insert_set_value_sorted(node_t *root, node_t *item);
get_item_sorted
Parameter Name |
Type |
Description |
s |
set_t |
Instance of set |
key |
char* |
String value to search for |
int get_item_sorted(set_t *s, char *key);
get_items_sorted
Parameter Name |
Type |
Description |
root |
node_t |
Root in set tree |
q |
queue_t |
Results stored in queue |
void get_items_sorted(node_t *root, queue_t *q);
print_set_sorted
Parameter Name |
Type |
Description |
s |
set_t |
Instance of set |
void print_set_sorted(set_t *s);
Ordered Set
Set data structure is used for handling unique items in a list in the order they're inserted.
struct OrderedSet {
int capacity, used, front, rear;
int *insert_counts;
node_t **items;
};
typedef struct OrderedSet ordered_set_t;
init_array_set
Parameter Name |
Type |
Description |
capacity |
int |
Max capacity of items inserted |
ordered_set_t *init_array_set(int capacity);
insert_ordered
Parameter Name |
Type |
Description |
s |
ordered_set_t |
Set instance |
id |
int |
Set ID |
string_value |
char* |
Character value |
weight |
int |
Weight value (for potential nodes) |
bool insert_ordered(ordered_set_t *s, int id, char *string_value, int weight);
get_insert_count
Parameter Name |
Type |
Description |
s |
ordered_set_t |
Set instance |
item |
node_t |
Item to insert |
int get_insert_count(ordered_set_t *s, node_t *item);
get_value_id
Parameter Name |
Type |
Description |
s |
ordered_set_t |
Set instance |
id |
int |
Set ID |
int get_value_id(ordered_set_t *s, int id);
get_value_key
Parameter Name |
Type |
Description |
s |
ordered_set_t |
Set instance |
key |
char |
Character value to search |
int get_value_key(ordered_set_t *s, char *key);
print_items_ordered
Parameter Name |
Type |
Description |
s |
ordered_set_t |
Set instance |
void print_items_ordered(ordered_set_t *s);