All these functions work on a group-structure. group_create() creates a new group-structure with one element in it. This element is the null-element. The datastructure is a cyclic double linked list. The function group_delete() deletes the group. All elements in the group are deleted by using the function elem_free.
To add elements to a group, group_add() is used. The element is added at the end of the list. group_insert() adds the element at the beginning of the list. To add only unique elements to the group, group_add_unique() is used. When elem is already in the group, it is not added and FALSE is returned, otherwise elem is added. The function equal defines the comparison of two elements in a group. The group can be used for integers but also for strings, structures, etc.
To visit every element in the double linked list, an iterator is used. To create an iterator for a specific group group_iterator() is called. There can be different iterators for the same group at the same time. When calling iter_next() (iter_previous()) with as parameter the iterator, the next (previous) element in the group is returned. The iterator is set to the next (previous) group-element. To retrieve the element of the group-element indicated by it, iterator_elem() is used, the iterator is not changed.
To delete a specific element in the group, group_del_previous() and group_del_next() are used. The difference between them is the position of the iterator after deletion. group_del_previous() (group_del_next()) sets iter on the previous (next) element in the group. If the group consist only of the null-element, i.e. the group is empty, no action is taken. The element is deleted using elem_free.
Both functions use group_delete() to do the deletion. tmp indicates the element to be deleted.
The content of the group is printed on file. The elements of the group must represents strings. This procedure is used for debugging purposes and for error reports.