Implement a growing insertion.

This commit is contained in:
2018-02-05 13:54:47 -08:00
parent 316d2daf89
commit c318aae32c
3 changed files with 63 additions and 4 deletions

View File

@@ -95,6 +95,16 @@ void sprs_free(sprs* sprs);
* @param data the value to store.
*/
void sprs_put(sprs* sprs, size_t index, void* data);
/**
* Stores a value in the sparse set under a given index.
* If the capacity of the sparse set is smaller than the given index,
* this grows the sparse set by doubling its size.
* @param sprs the sparse set into which to store the value.
* @param index the index at which to store the value.
* @param data the value to store.
* @return LIBDS_SUCCESS if all goes well, or LIBDS_MALLOC if the growing failed.
*/
libds_result sprs_put_grow(sprs* sprs, size_t index, void* data);
/**
* Checks if the sparse set contains data under a given index.
* @param sprs the sparse set to check.