set.h
Go to the documentation of this file.
/*
Copyright (C) 2022 The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file COPYING for details.
*/
#ifndef SET_H
#define SET_H
#include "int_sizes.h"
#include "list.h"
#define SET_ITERATE( set, element ) set_first_element(set); while((element = set_next_element(set)))
#define SET_ITERATE_RANDOM_START( set, offset_bookkeep, element ) set_random_element(set, &offset_bookkeep); while((element = set_next_element_with_offset(set, offset_bookkeep)))
struct set *set_create(int buckets);
struct set *set_duplicate(struct set *s);
struct set *set_union(struct set *s1, struct set *s2);
void set_clear(struct set *s);
void set_delete(struct set *s);
int set_size(struct set *s);
int set_insert(struct set *s, const void *element);
int set_insert_set(struct set *s, struct set *s2);
int set_insert_list(struct set *s, struct list *l);
int set_push(struct set *h, const void *element);
int set_lookup(struct set *s, void *element);
int set_remove(struct set *s, const void *element);
void *set_pop(struct set *s);
void set_first_element(struct set *s);
void *set_next_element(struct set *s);
void set_random_element(struct set *s, int *offset_bookkeep);
void *set_next_element_with_offset(struct set *s, int offset_bookkeep);
void **set_values(struct set *s);
void **set_values_array(struct set *s);
void set_free_values_array(void **values);
#endif
list.h
Robust, reentrant linked list structure.
set_create
struct set * set_create(int buckets)
Create a new set.
set_insert_set
int set_insert_set(struct set *s, struct set *s2)
Insert an existing set into the set.
set_size
int set_size(struct set *s)
Count the entries in a set.
set_delete
void set_delete(struct set *s)
Delete a set.
set_union
struct set * set_union(struct set *s1, struct set *s2)
Unions two sets into one set.
set_insert_list
int set_insert_list(struct set *s, struct list *l)
Insert an existing list into the set.
set_insert
int set_insert(struct set *s, const void *element)
Insert an element to the set.
set_clear
void set_clear(struct set *s)
Remove all entries from a set.
set_first_element
void set_first_element(struct set *s)
Begin iteration over all the elements.
set_pop
void * set_pop(struct set *s)
Remove an arbitrary element from the set.
set_next_element
void * set_next_element(struct set *s)
Continue iteration over all elements.
set_random_element
void set_random_element(struct set *s, int *offset_bookkeep)
Begin iteration over all elements from a random offset.
set_values
void ** set_values(struct set *s)
A set_size(s) array of the current elements in the set in a random order.
set_push
int set_push(struct set *h, const void *element)
Insert an element to the set.
set_values_array
void ** set_values_array(struct set *s)
A set_size(s) + 1 array of the current elements in the set in a random order.
set_free_values_array
void set_free_values_array(void **values)
Free an array returned by set_values_array.
set_lookup
int set_lookup(struct set *s, void *element)
Look up a element in the set.
set_duplicate
struct set * set_duplicate(struct set *s)
Duplicate a set from an existing set.
set_next_element_with_offset
void * set_next_element_with_offset(struct set *s, int offset_bookkeep)
Continue iteration over all elements from an arbitray offset.
set_remove
int set_remove(struct set *s, const void *element)
Remove an element.