diff options
| author | Tyge Løvset <[email protected]> | 2021-10-30 19:29:15 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-10-30 19:29:15 +0200 |
| commit | 89ee23a74687311c5234f832d782b5ad56e2de7f (patch) | |
| tree | d10ad622bd29041c2ca05e24107a9136a21ab06f | |
| parent | 0a290000211562ffc5b39a7842a7f7fedb48baea (diff) | |
| download | STC-modified-89ee23a74687311c5234f832d782b5ad56e2de7f.tar.gz STC-modified-89ee23a74687311c5234f832d782b5ad56e2de7f.zip | |
Fixed docs alignments.
| -rw-r--r-- | docs/clist_api.md | 14 | ||||
| -rw-r--r-- | docs/cmap_api.md | 2 | ||||
| -rw-r--r-- | docs/cset_api.md | 2 | ||||
| -rw-r--r-- | docs/csmap_api.md | 6 | ||||
| -rw-r--r-- | docs/csset_api.md | 8 | ||||
| -rw-r--r-- | docs/csview_api.md | 2 | ||||
| -rw-r--r-- | docs/cvec_api.md | 12 | ||||
| -rw-r--r-- | examples/list_erase.c | 23 | ||||
| -rw-r--r-- | include/stc/clist.h | 11 |
9 files changed, 38 insertions, 42 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md index 6bb241f9..a00b9551 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -146,15 +146,15 @@ int main () { clist_i L = clist_i_init(); c_apply(clist_i, push_back, &L, {10, 20, 30, 40, 50}); - // 10 20 30 40 50 - clist_i_iter it = clist_i_begin(&L); // ^ + // 10 20 30 40 50 + clist_i_iter it = clist_i_begin(&L); // ^ clist_i_next(&it); - it = clist_i_erase_at(&L, it); // 10 30 40 50 - // ^ - clist_i_iter end = clist_i_end(&L); // + it = clist_i_erase_at(&L, it); // 10 30 40 50 + // ^ + clist_i_iter end = clist_i_end(&L); // clist_i_next(&it); - it = clist_i_erase_range(&L, it, end); // 10 30 - // ^ + it = clist_i_erase_range(&L, it, end); // 10 30 + // ^ printf("mylist contains:"); c_foreach (x, clist_i, L) printf(" %d", *x.ref); puts(""); diff --git a/docs/cmap_api.md b/docs/cmap_api.md index f8b24704..9bdafcb9 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -67,7 +67,7 @@ cmap_X_result cmap_X_emplace(cmap_X* self, i_keyraw rkey, i_valraw rmapped cmap_X_result cmap_X_emplace_or_assign(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped size_t cmap_X_erase(cmap_X* self, i_keyraw rkey); // return 0 or 1 -cmap_X_iter cmap_X_erase_at(cmap_X* self, cmap_X_iter it); // return iter after it +cmap_X_iter cmap_X_erase_at(cmap_X* self, cmap_X_iter it); // return iter after it void cmap_X_erase_entry(cmap_X* self, cmap_X_value* entry); cmap_X_iter cmap_X_begin(const cmap_X* self); diff --git a/docs/cset_api.md b/docs/cset_api.md index c422fdb2..04a1617f 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -48,7 +48,7 @@ cset_X_result cset_X_insert(cset_X* self, i_key key); cset_X_result cset_X_emplace(cset_X* self, i_keyraw rkey);
size_t cset_X_erase(cset_X* self, i_keyraw rkey); // return 0 or 1
-cset_X_iter cset_X_erase_at(cset_X* self, cset_X_iter it); // return iter after it
+cset_X_iter cset_X_erase_at(cset_X* self, cset_X_iter it); // return iter after it
void cset_X_erase_entry(cset_X* self, cset_X_value* entry);
cset_X_iter cset_X_begin(const cset_X* self);
diff --git a/docs/csmap_api.md b/docs/csmap_api.md index 96d71d30..7a528c7b 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -50,7 +50,7 @@ csmap_X_mapped* csmap_X_at(const csmap_X* self, i_keyraw rkey); csmap_X_value* csmap_X_get(const csmap_X* self, i_keyraw rkey); // return NULL if not found csmap_X_iter csmap_X_lower_bound(const csmap_X* self, i_keyraw rkey); // find closest entry >= rkey csmap_X_iter csmap_X_find(const csmap_X* self, i_keyraw rkey); -csmap_X_value* csmap_X_find_it(const csmap_X* self, i_keyraw rkey, csmap_X_iter* out); // return NULL if not found +csmap_X_value* csmap_X_find_it(const csmap_X* self, i_keyraw rkey, csmap_X_iter* out); // return NULL if not found csmap_X_result csmap_X_insert(csmap_X* self, i_key key, i_val mapped); // no change if key in map csmap_X_result csmap_X_insert_or_assign(csmap_X* self, i_key key, i_val mapped); // always update mapped @@ -60,8 +60,8 @@ csmap_X_result csmap_X_emplace(csmap_X* self, i_keyraw rkey, i_valraw rmapp csmap_X_result csmap_X_emplace_or_assign(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped size_t csmap_X_erase(csmap_X* self, i_keyraw rkey); -csmap_X_iter csmap_X_erase_at(csmap_X* self, csmap_X_iter it); // returns iter after it -csmap_X_iter csmap_X_erase_range(csmap_X* self, csmap_X_iter it1, csmap_X_iter it2); // returns updated it2 +csmap_X_iter csmap_X_erase_at(csmap_X* self, csmap_X_iter it); // returns iter after it +csmap_X_iter csmap_X_erase_range(csmap_X* self, csmap_X_iter it1, csmap_X_iter it2); // returns updated it2 csmap_X_iter csmap_X_begin(const csmap_X* self); csmap_X_iter csmap_X_end(const csmap_X* self); diff --git a/docs/csset_api.md b/docs/csset_api.md index 22573b25..41e0063f 100644 --- a/docs/csset_api.md +++ b/docs/csset_api.md @@ -28,14 +28,14 @@ csset_X csset_X_clone(csset_x set); void csset_X_clear(csset_X* self);
void csset_X_copy(csset_X* self, csset_X other);
void csset_X_swap(csset_X* a, csset_X* b);
-void csset_X_del(csset_X* self); // destructor
+void csset_X_del(csset_X* self); // destructor
bool csset_X_empty(csset_X set);
size_t csset_X_size(csset_X set);
bool csset_X_contains(const csset_X* self, i_keyraw rkey);
-csset_X_value* csset_X_get(const csset_X* self, i_keyraw rkey); // return NULL if not found
-csset_X_iter csset_X_lower_bound(const csset_X* self, i_keyraw rkey); // find closest entry >= rkey
+csset_X_value* csset_X_get(const csset_X* self, i_keyraw rkey); // return NULL if not found
+csset_X_iter csset_X_lower_bound(const csset_X* self, i_keyraw rkey); // find closest entry >= rkey
csset_X_iter csset_X_find(const csset_X* self, i_keyraw rkey);
csset_X_value* csset_X_find_it(const csset_X* self, i_keyraw rkey, csset_X_iter* out); // return NULL if not found
@@ -44,7 +44,7 @@ csset_X_result csset_X_emplace(csset_X* self, i_keyraw rkey); size_t csset_X_erase(csset_X* self, i_keyraw rkey);
csset_X_iter csset_X_erase_at(csset_X* self, csset_X_iter it); // return iter after it
-csset_X_iter csset_X_erase_range(csset_X* self, csset_X_iter it1, csset_X_iter it2); // return updated it2
+csset_X_iter csset_X_erase_range(csset_X* self, csset_X_iter it1, csset_X_iter it2); // return updated it2
csset_X_iter csset_X_begin(const csset_X* self);
csset_X_iter csset_X_end(const csset_X* self);
diff --git a/docs/csview_api.md b/docs/csview_api.md index 4d80692d..1376b768 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -80,7 +80,7 @@ bool cstr_ends_with_v(cstr s, csview sub); ```c int csview_compare(const csview* x, const csview* y); bool csview_equalto(const csview* x, const csview* y); -uint64_t csview_hash(const csview* x, ...); +uint64_t csview_hash(const csview* x, size_t dummy); ``` ## Types diff --git a/docs/cvec_api.md b/docs/cvec_api.md index 9953bb4b..42ec944e 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -39,7 +39,7 @@ void cvec_X_shrink_to_fit(cvec_X* self); void cvec_X_reserve(cvec_X* self, size_t cap); void cvec_X_resize(cvec_X* self, size_t size, i_val fill); void cvec_X_swap(cvec_X* a, cvec_X* b); -void cvec_X_del(cvec_X* self); // destructor +void cvec_X_del(cvec_X* self); // destructor bool cvec_X_empty(cvec_X vec); size_t cvec_X_size(cvec_X vec); @@ -53,15 +53,15 @@ cvec_X_value* cvec_X_push_back(cvec_X* self, i_val value); cvec_X_value* cvec_X_emplace_back(cvec_X* self, i_valraw raw); void cvec_X_pop_back(cvec_X* self); -cvec_X_iter cvec_X_insert(cvec_X* self, size_t idx, i_val value); // move value -cvec_X_iter cvec_X_insert_n(cvec_X* self, size_t idx, const i_val[] arr, size_t n); // move arr values -cvec_X_iter cvec_X_insert_at(cvec_X* self, cvec_X_iter it, i_val value); // move value +cvec_X_iter cvec_X_insert(cvec_X* self, size_t idx, i_val value); // move value +cvec_X_iter cvec_X_insert_n(cvec_X* self, size_t idx, const i_val[] arr, size_t n); // move arr values +cvec_X_iter cvec_X_insert_at(cvec_X* self, cvec_X_iter it, i_val value); // move value cvec_X_iter cvec_X_emplace(cvec_X* self, size_t idx, i_valraw raw); cvec_X_iter cvec_X_emplace_n(cvec_X* self, size_t idx, const i_valraw[] arr, size_t n); cvec_X_iter cvec_X_emplace_at(cvec_X* self, cvec_X_iter it, i_valraw raw); cvec_X_iter cvec_X_emplace_range(cvec_X* self, cvec_X_iter it, - cvec_X_iter it1, cvec_X_iter it2); // will clone + cvec_X_iter it1, cvec_X_iter it2); // will clone cvec_X_iter cvec_X_emplace_range_p(cvec_X* self, i_val* pos, const i_val* p1, const i_val* p2); @@ -71,7 +71,7 @@ cvec_X_iter cvec_X_erase_range(cvec_X* self, cvec_X_iter it1, cvec_X_ite cvec_X_iter cvec_X_find(const cvec_X* self, i_valraw raw); cvec_X_iter cvec_X_find_in(cvec_X_iter i1, cvec_X_iter i2, i_valraw raw); -cvec_X_value* cvec_X_get(const cvec_X* self, i_valraw raw); // return NULL if not found +cvec_X_value* cvec_X_get(const cvec_X* self, i_valraw raw); // return NULL if not found cvec_X_iter cvec_X_bsearch(const cvec_X* self, i_valraw raw); cvec_X_iter cvec_X_bsearch_in(cvec_X_iter i1, cvec_X_iter i2, i_valraw raw); diff --git a/examples/list_erase.c b/examples/list_erase.c index e2db62d5..c567f043 100644 --- a/examples/list_erase.c +++ b/examples/list_erase.c @@ -2,25 +2,26 @@ #include <stdio.h>
#define i_val int
-#define i_tag i
#include <stc/clist.h>
int main ()
{
- c_autovar (clist_i L = clist_i_init(), clist_i_del(&L))
+ c_auto (clist_int, L)
{
- c_apply(clist_i, push_back, &L, {10, 20, 30, 40, 50});
+ c_apply(clist_int, push_back, &L, {10, 20, 30, 40, 50});
+ c_foreach (x, clist_int, L) printf("%d ", *x.ref);
+ puts("");
// 10 20 30 40 50
- clist_i_iter it = clist_i_begin(&L); // ^
- clist_i_next(&it);
- it = clist_i_erase_at(&L, it); // 10 30 40 50
+ clist_int_iter it = clist_int_begin(&L); // ^
+ clist_int_next(&it);
+ it = clist_int_erase_at(&L, it); // 10 30 40 50
// ^
- clist_i_iter end = clist_i_end(&L); //
- clist_i_next(&it);
- it = clist_i_erase_range(&L, it, end); // 10 30
+ clist_int_iter end = clist_int_end(&L); //
+ clist_int_next(&it);
+ it = clist_int_erase_range(&L, it, end); // 10 30
// ^
- printf("mylist contains:");
- c_foreach (x, clist_i, L) printf(" %d", *x.ref);
+ printf("list contains:");
+ c_foreach (x, clist_int, L) printf(" %d", *x.ref);
puts("");
}
}
diff --git a/include/stc/clist.h b/include/stc/clist.h index 0c023afa..a97c9526 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -132,11 +132,6 @@ _cx_memb(_copy)(_cx_self *self, _cx_self other) { }
STC_INLINE _cx_iter
-_cx_memb(_iterator)(const _cx_self* self, _cx_node* prev) {
- return c_make(_cx_iter){&prev->next->value, &self->last, prev};
-}
-
-STC_INLINE _cx_iter
_cx_memb(_begin)(const _cx_self* self) {
_cx_value* head = self->last ? &self->last->next->value : NULL;
return c_make(_cx_iter){head, &self->last, self->last};
@@ -161,7 +156,7 @@ _cx_memb(_advance)(_cx_iter it, size_t n) { STC_INLINE _cx_iter
_cx_memb(_splice_range)(_cx_self* self, _cx_iter it,
- _cx_self* other, _cx_iter it1, _cx_iter it2) {
+ _cx_self* other, _cx_iter it1, _cx_iter it2) {
_cx_self tmp = _cx_memb(_split_off)(other, it1, it2);
return _cx_memb(_splice)(self, it, &tmp);
}
@@ -229,7 +224,7 @@ _cx_memb(_erase_at)(_cx_self* self, _cx_iter it) { STC_DEF _cx_iter
_cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2) {
_cx_node *node = it1.ref ? it1.prev : NULL,
- *done = it2.ref ? clist_node_(it2.ref) : NULL;
+ *done = it2.ref ? clist_node_(it2.ref) : NULL;
while (node && node->next != done)
node = _cx_memb(_erase_after_)(self, node);
return it2;
@@ -288,7 +283,7 @@ _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2) { _cx_self cx = {NULL};
if (it1.ref == it2.ref) return cx;
_cx_node *p1 = it1.prev,
- *p2 = it2.ref ? it2.prev : self->last;
+ *p2 = it2.ref ? it2.prev : self->last;
p1->next = p2->next, p2->next = clist_node_(it1.ref);
if (self->last == p2) self->last = (p1 == p2) ? NULL : p1;
cx.last = p2;
|
