-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove submodule, add source files (#134)
* remove submodule * add alex-c-collections, remove submodule
- Loading branch information
1 parent
9170e30
commit 2f946a8
Showing
19 changed files
with
1,360 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
unusedFunction:lib/col/*c | ||
unusedFunction:tst/wrap-log.c | ||
unusedFunction:tst/util.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule alex-c-collections
deleted from
4c3f2b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[email protected]:alex-courtis/alex-c-collections.git v1.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#ifndef ITABLE_H | ||
#define ITABLE_H | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
/* | ||
* Array backed integer indexed table. | ||
* Entries preserve insertion order. | ||
* Operations linearly traverse keys. | ||
* NULL values permitted. | ||
* Not thread safe. | ||
*/ | ||
struct ITable; | ||
|
||
/* | ||
* Entry iterator. | ||
*/ | ||
struct ITableIter { | ||
const uint64_t key; | ||
const void* const val; | ||
}; | ||
|
||
/* | ||
* Lifecycle | ||
*/ | ||
|
||
// construct a table with initial size, growing as necessary, NULL on zero param | ||
const struct ITable *itable_init(const size_t initial, const size_t grow); | ||
|
||
// free table | ||
void itable_free(const void* const tab); | ||
|
||
// free table and vals, null free_val uses free() | ||
void itable_free_vals(const struct ITable* const tab, void (*free_val)(const void* const val)); | ||
|
||
// free iter | ||
void itable_iter_free(const struct ITableIter* const iter); | ||
|
||
/* | ||
* Access | ||
*/ | ||
|
||
// return val, NULL not present | ||
const void *itable_get(const struct ITable* const tab, const uint64_t key); | ||
|
||
// create an iterator, caller must itable_iter_free or invoke itable_next until NULL | ||
const struct ITableIter *itable_iter(const struct ITable* const tab); | ||
|
||
// next iterator value, NULL at end of list | ||
const struct ITableIter *itable_next(const struct ITableIter* const iter); | ||
|
||
// number of entries with val | ||
size_t itable_size(const struct ITable* const tab); | ||
|
||
/* | ||
* Mutate | ||
*/ | ||
|
||
// set key/val, return old val if overwritten | ||
const void *itable_put(const struct ITable* const tab, const uint64_t key, const void* const val); | ||
|
||
// remove key, return old val if present | ||
const void *itable_remove(const struct ITable* const tab, const uint64_t key); | ||
|
||
#endif // ITABLE_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef OSET_H | ||
#define OSET_H | ||
|
||
#include <stdbool.h> | ||
#include <stddef.h> | ||
|
||
/* | ||
* Array backed ordered set. | ||
* Operations linearly traverse values. | ||
* NULL not permitted. | ||
* Not thread safe. | ||
*/ | ||
struct OSet; | ||
|
||
/* | ||
* Entry iterator. | ||
*/ | ||
struct OSetIter { | ||
const void* const val; | ||
}; | ||
|
||
/* | ||
* Lifecycle | ||
*/ | ||
|
||
// construct a set with initial size, grow as needed, NULL on zero param | ||
const struct OSet *oset_init(const size_t initial, const size_t grow); | ||
|
||
// free set | ||
void oset_free(const void* const set); | ||
|
||
// free map and vals, NULL free_val uses free() | ||
void oset_free_vals(const struct OSet* const set, void (*free_val)(const void* const val)); | ||
|
||
// free iter | ||
void oset_iter_free(const struct OSetIter* const iter); | ||
|
||
/* | ||
* Access | ||
*/ | ||
|
||
// true if this set contains the specified element | ||
bool oset_contains(const struct OSet* const set, const void* const val); | ||
|
||
// number of values | ||
size_t oset_size(const struct OSet* const set); | ||
|
||
// create an iterator, caller must oset_iter_free or invoke oset_next until NULL | ||
const struct OSetIter *oset_iter(const struct OSet* const set); | ||
|
||
// next iterator value, NULL at end of set | ||
const struct OSetIter *oset_next(const struct OSetIter* const iter); | ||
|
||
/* | ||
* Mutate | ||
*/ | ||
|
||
// true if this set did not already contain the specified element | ||
bool oset_add(const struct OSet* const set, const void* const val); | ||
|
||
// true if this set contained the element | ||
bool oset_remove(const struct OSet* const set, const void* const val); | ||
|
||
#endif // OSET_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef PTABLE_H | ||
#define PTABLE_H | ||
|
||
#include <stddef.h> | ||
|
||
/* | ||
* ITable convenience wrapper with pointer key. | ||
*/ | ||
struct PTable; | ||
|
||
/* | ||
* Entry iterator. | ||
*/ | ||
struct PTableIter { | ||
const void *key; | ||
const void *val; | ||
}; | ||
|
||
/* | ||
* Lifecycle | ||
*/ | ||
|
||
// construct a table with initial size, growing as necessary, NULL on zero param | ||
const struct PTable *ptable_init(const size_t initial, const size_t grow); | ||
|
||
// free table | ||
void ptable_free(const void* const tab); | ||
|
||
// free table and vals, null free_val uses free() | ||
void ptable_free_vals(const struct PTable* const tab, void (*free_val)(const void* const val)); | ||
|
||
// free iter | ||
void ptable_iter_free(const struct PTableIter* const iter); | ||
|
||
/* | ||
* Access | ||
*/ | ||
|
||
// return val, NULL not present | ||
const void *ptable_get(const struct PTable* const tab, const void* const key); | ||
|
||
// create an iterator, caller must ptable_iter_free or invoke ptable_next until NULL | ||
const struct PTableIter *ptable_iter(const struct PTable* const tab); | ||
|
||
// next iterator value, NULL at end of list | ||
const struct PTableIter *ptable_next(const struct PTableIter* const iter); | ||
|
||
// number of entries with val | ||
size_t ptable_size(const struct PTable* const tab); | ||
|
||
/* | ||
* Mutate | ||
*/ | ||
|
||
// set key/val, return old val if overwritten, NULL val to remove | ||
const void *ptable_put(const struct PTable* const tab, const void* const key, const void* const val); | ||
|
||
#endif // PTABLE_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#ifndef SLIST_H | ||
#define SLIST_H | ||
|
||
#include <stdbool.h> | ||
#include <stddef.h> | ||
|
||
struct SList { | ||
void *val; | ||
struct SList *nex; | ||
}; | ||
|
||
/* | ||
* Lifecycle | ||
*/ | ||
|
||
// clone the list, setting val pointers | ||
struct SList *slist_shallow_clone(struct SList *head); | ||
|
||
// free list | ||
void slist_free(struct SList **head); | ||
|
||
// free list and vals, NULL free_val uses free() | ||
void slist_free_vals(struct SList **head, void (*free_val)(void *val)); | ||
|
||
/* | ||
* Mutate | ||
*/ | ||
|
||
// append val to a list | ||
struct SList *slist_append(struct SList **head, void *val); | ||
|
||
// remove an item, returning the val | ||
void *slist_remove(struct SList **head, struct SList **item); | ||
|
||
// remove items, NULL predicate is val pointer comparison | ||
size_t slist_remove_all(struct SList **head, bool (*predicate)(const void *val, const void *data), const void *data); | ||
|
||
// remove items and free vals, NULL predicate is val pointer comparison, NULL free_val calls free() | ||
size_t slist_remove_all_free(struct SList **head, bool (*predicate)(const void *val, const void *data), const void *data, void (*free_val)(void *val)); | ||
|
||
/* | ||
* Access | ||
*/ | ||
|
||
// val at position | ||
void *slist_at(struct SList *head, size_t index); | ||
|
||
// find | ||
struct SList *slist_find(struct SList *head, bool (*test)(const void *val)); | ||
|
||
// find a val | ||
void *slist_find_val(struct SList *head, bool (*test)(const void *val)); | ||
|
||
// find, NULL predicate is val pointer comparison | ||
struct SList *slist_find_equal(struct SList *head, bool (*predicate)(const void *val, const void *data), const void *data); | ||
|
||
// find a val, NULL predicate is val pointer comparison | ||
void *slist_find_equal_val(struct SList *head, bool (*predicate)(const void *val, const void *data), const void *data); | ||
|
||
// same length and every item passes test in order, NULL equal compares pointers | ||
bool slist_equal(struct SList *a, struct SList *b, bool (*equal)(const void *a, const void *b)); | ||
|
||
/* | ||
* Utility | ||
*/ | ||
|
||
// length | ||
size_t slist_length(struct SList *head); | ||
|
||
// sort into a new list | ||
struct SList *slist_sort(struct SList *head, bool (*before)(const void *a, const void *b)); | ||
|
||
// move items between lists with predicate, NULL predicate does nothing | ||
void slist_move(struct SList **to, struct SList **from, bool (*predicate)(const void *val, const void *data), const void *data); | ||
|
||
/* | ||
* Predicate | ||
*/ | ||
|
||
// test val for equality using strcmp | ||
bool slist_predicate_strcmp(const void *val, const void *data); | ||
|
||
#endif // SLIST_H | ||
|
Oops, something went wrong.