Commit graph

7 commits

Author SHA1 Message Date
Bill Currie
b9599a7119 Better set memory management.
At the cost of one pointer per set, sets can now be allocated and freed
more efficiently (especially since malloc might round things up).
2012-11-15 13:44:07 +09:00
Bill Currie
2385cf65c2 Rename setstate_t to set_iter_t.
After all, it is an iterator :).
2012-11-15 13:44:07 +09:00
Bill Currie
388b6e6e8f Add set_size ().
Return the number of members in the set.
2012-11-15 13:44:07 +09:00
Bill Currie
8567508963 Rewrite set_first() and add set_next().
set_first() now returns a pointer to a setstate_t struct that holds the
state necessary for scanning a set. set_next() will automatically delete
the state block when the end of the set is reached. set_delstate() is also
provided to allow early termination of the scan.
2012-11-15 13:44:07 +09:00
Bill Currie
8fb958603c Add set_first.
It returns the first element of a set. If the set is empty, -1 (unsigned)
is returned.
2012-11-15 13:44:07 +09:00
Bill Currie
964ea7f9fe Add set_as_string for debug output. 2012-11-15 13:44:07 +09:00
Bill Currie
cdc790d0c8 Add a set type and support code. 2012-11-15 13:44:06 +09:00