#ifndef __ISET_H__ #define __ISET_H__ #include /** * A set of integers implemeted with an unbalanced binary search tree. * * @version 0.1 2018-11-06 from F2017 isset.c; Blue https://upload.wikimedia.org/wikipedia/commons/4/48/Tidal_Bore_-_geograph.org.uk_-_324581.jpg or https://commons.wikimedia.org/wiki/File:Empty_wave_at_Banzai_Pipeline.jpeg ? */ typedef struct iset iset; /** * Creates a set of integers. * * @return a pointer to a new empty set of integers */ iset *iset_create(); /** * Returns the total number of integers in the given set. * * @param s a pointer to a set, non-NULL * @return the total number of integers in that set */ int iset_size(const iset *s); /** * Determines whether the given integer is in the given set. * * @param s a pointer to a set, non-NULL * @param item an integer */ bool iset_contains(const iset *s, int item); /** * Adds the given integer to the given set. * * @param s a pointer to a set, non-NULL * @param item an integer * @return true if and only if the item was not in the set and was added */ bool iset_add(iset *s, int item); /** * Removes the given integer from the given set. * * @param s a pointer to a set, non-NULL * @param item an integer * @return true if and only if the item was in the set */ bool iset_remove(iset *s, int item); /** * Passes each item in this set to the given function. That function is * also passed an implementation-dependent int and the extr argument. * * @param s a pointer to a set, non-NULL * @param f a pointer to a function, non-NULL * @param a a pointer */ void iset_for_each(iset *s, void (*f)(int, int, void *), void *a); /** * Destroys the given set. * * @param s a pointer to a set, non-NULL */ void iset_destroy(iset *s); #endif