summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-28 15:20:33 +0200
committerTyge Løvset <[email protected]>2022-04-28 15:20:33 +0200
commitc68b5bac81319612e94b231af234bad6ef559c61 (patch)
treed09e899d69a7d146f2b741c308036c545167be8d /include
parentc542a17addd954ef0c5c9c9a80c368773a3d98b7 (diff)
downloadSTC-modified-c68b5bac81319612e94b231af234bad6ef559c61.tar.gz
STC-modified-c68b5bac81319612e94b231af234bad6ef559c61.zip
_i_implement moved to user-level template parameter as i_implement. Removed i_opt flag c_implement. Removed OLD include/alt/clist.h
Diffstat (limited to 'include')
-rw-r--r--include/stc/alt/clist.h367
-rw-r--r--include/stc/alt/csmap.h2
-rw-r--r--include/stc/alt/cstr.h2
-rw-r--r--include/stc/carr2.h2
-rw-r--r--include/stc/carr3.h2
-rw-r--r--include/stc/cbits.h2
-rw-r--r--include/stc/ccommon.h11
-rw-r--r--include/stc/cdeq.h2
-rw-r--r--include/stc/clist.h4
-rw-r--r--include/stc/cmap.h12
-rw-r--r--include/stc/cpque.h2
-rw-r--r--include/stc/crandom.h2
-rw-r--r--include/stc/csmap.h4
-rw-r--r--include/stc/cstr.h4
-rw-r--r--include/stc/csview.h2
-rw-r--r--include/stc/cvec.h4
-rw-r--r--include/stc/utf8.h2
17 files changed, 33 insertions, 393 deletions
diff --git a/include/stc/alt/clist.h b/include/stc/alt/clist.h
deleted file mode 100644
index d16c1c21..00000000
--- a/include/stc/alt/clist.h
+++ /dev/null
@@ -1,367 +0,0 @@
-/* MIT License
- *
- * Copyright (c) 2022 Tyge Løvset, NORCE, www.norceresearch.no
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef CLIST_H_INCLUDED
-#define CLIST_H_INCLUDED
-
-/* Circular Singly-linked Lists.
-
- This implements a std::forward_list-like class in C, but because it is circular,
- it also support push* and splice* at both ends of the list. This makes it ideal
- for being used as a queue, unlike std::forward_list. Basic usage is similar to cvec:
-
- #include <stdio.h>
- #include <stc/clist.h>
- #include <stc/crandom.h>
- using_clist(ix, int64_t);
-
- int main() {
- clist_ix list = clist_ix_init();
- stc64_t rng = stc64_new(12345);
- int n;
- for (int i=0; i<1000000; ++i) // one million
- clist_ix_push_back(&list, stc64_rand(&rng) >> 32);
- n = 0;
- c_foreach (i, clist_ix, list)
- if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.ref->value);
- // Sort them...
- clist_ix_sort(&list); // mergesort O(n*log n)
- n = 0;
- puts("sorted");
- c_foreach (i, clist_ix, list)
- if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.ref->value);
- clist_ix_drop(&list);
- }
-*/
-#include <stc/ccommon.h>
-#include <stdlib.h>
-
-
-
-_c_clist_types(clist_VOID, int);
-STC_API size_t _clist_count(const clist_VOID* self);
-#define _clist_node(_cx_self, vp) c_container_of(vp, _cx_node, value)
-
-#define _c_using_clist(_cx_self, i_val, i_cmp, i_valdrop, i_valfrom, i_valto, i_valraw, defTypes) \
-\
- defTypes( _c_clist_types(_cx_self, i_val); ) \
- typedef i_valraw _cx_raw; \
-\
- STC_API _cx_self _cx_memb(_clone)(_cx_self lst); \
- STC_API void _cx_memb(_drop)(_cx_self* self); \
- STC_API void _cx_memb(_push_back)(_cx_self* self, i_val value); \
- STC_API void _cx_memb(_push_front)(_cx_self* self, i_val value); \
- STC_API void _cx_memb(_emplace_items)(_cx_self *self, const _cx_raw arr[], size_t n); \
- STC_API _cx_self _cx_memb(_split_after)(_cx_self* self, _cx_iter pos1, _cx_iter pos2); \
- STC_API void _cx_memb(_splice_after)(_cx_self* self, _cx_iter pos, _cx_self* other); \
- STC_DEF void _cx_memb(_splice_after_range)(_cx_self* self, _cx_iter pos, _cx_self* other, _cx_iter i1, _cx_iter i2); \
- STC_API _cx_iter _cx_memb(_find)(const _cx_self* self, i_valraw val); \
- STC_API _cx_iter _cx_memb(_find_before)(const _cx_self* self, i_valraw val); \
- STC_API _cx_iter _cx_memb(_find_before_in)(_cx_iter it1, _cx_iter it2, i_valraw val); \
- STC_API void _cx_memb(_sort)(_cx_self* self); \
- STC_API size_t _cx_memb(_remove)(_cx_self* self, i_valraw val); \
- STC_API _cx_iter _cx_memb(_insert_after)(_cx_self* self, _cx_iter pos, i_val value); \
- STC_API _cx_iter _cx_memb(_erase_after)(_cx_self* self, _cx_iter pos); \
- STC_API _cx_iter _cx_memb(_erase_range_after)(_cx_self* self, _cx_iter pos, _cx_iter it2); \
- STC_API _cx_node* _cx_memb(_erase_after_)(_cx_self* self, _cx_node* node); \
-\
- STC_INLINE _cx_self _cx_memb(_init)(void) {_cx_self lst = {NULL}; return lst; } \
- STC_INLINE bool _cx_memb(_empty)(_cx_self lst) { return lst.last == NULL; } \
- STC_INLINE size_t _cx_memb(_count)(_cx_self lst) { return _clist_count((const clist_VOID*) &lst); } \
- STC_INLINE i_val _cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); } \
- STC_INLINE i_val _cx_memb(_value_clone)(i_val val) { i_valraw _r = i_valto((&val)); return i_valfrom(_r); } \
- STC_INLINE void _cx_memb(_clear)(_cx_self* self) { _cx_memb(_drop)(self); } \
- STC_INLINE void _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) \
- { _cx_memb(_push_back)(self, i_valfrom(raw)); } \
- STC_INLINE void _cx_memb(_emplace_front)(_cx_self* self, i_valraw raw) \
- { _cx_memb(_push_front)(self, i_valfrom(raw)); } \
- STC_INLINE _cx_value* \
- _cx_memb(_front)(const _cx_self* self) { return &self->last->next->value; } \
- STC_INLINE _cx_value* \
- _cx_memb(_back)(const _cx_self* self) { return &self->last->value; } \
- STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) { _cx_memb(_erase_after_)(self, self->last); } \
- STC_INLINE void _cx_memb(_splice_front)(_cx_self* self, _cx_self* other) \
- { _cx_memb(_splice_after)(self, _cx_memb(_before_begin)(self), other); } \
- STC_INLINE void _cx_memb(_splice_back)(_cx_self* self, _cx_self* other) \
- { _cx_memb(_splice_after)(self, _cx_memb(_last)(self), other); } \
-\
- STC_INLINE _cx_iter \
- _cx_memb(_emplace_after)(_cx_self* self, _cx_iter pos, i_valraw raw) { \
- return _cx_memb(_insert_after)(self, pos, i_valfrom(raw)); \
- } \
-\
- STC_INLINE _cx_iter \
- _cx_memb(_before_begin)(const _cx_self* self) { \
- _cx_value *last = self->last ? &self->last->value : NULL; \
- _cx_iter it = {&self->last, last, -1}; return it; \
- } \
-\
- STC_INLINE _cx_iter \
- _cx_memb(_begin)(const _cx_self* self) { \
- _cx_value* head = self->last ? &self->last->next->value : NULL; \
- _cx_iter it = {&self->last, head, 0}; return it; \
- } \
-\
- STC_INLINE _cx_iter \
- _cx_memb(_last)(const _cx_self* self) { \
- _cx_value *last = self->last ? &self->last->value : NULL; \
- _cx_iter it = {&self->last, last, 0}; return it; \
- } \
-\
- STC_INLINE _cx_iter \
- _cx_memb(_end)(const _cx_self* self) { \
- _cx_iter it = {NULL, NULL}; return it; \
- } \
-\
- STC_INLINE void \
- _cx_memb(_next)(_cx_iter* it) { \
- _cx_node* node = _clist_node(_cx_self, it->ref); \
- it->ref = ((it->_state += node == *it->_last) == 1) ? NULL : &node->next->value; \
- } \
-\
- STC_INLINE _cx_iter \
- _cx_memb(_advance)(_cx_iter it, size_t n) { \
- while (n-- && it.ref) _cx_memb(_next)(&it); return it; \
- } \
- \
- _c_implement_clist(_cx_self, i_val, i_cmp, i_valdrop, i_valfrom, i_valto, i_valraw) \
- struct stc_trailing_semicolon
-
-/* -------------------------- IMPLEMENTATION ------------------------- */
-
-#if defined(_i_implement)
-#define _c_implement_clist(_cx_self, i_val, i_cmp, i_valdrop, i_valfrom, i_valto, i_valraw) \
-\
- STC_DEF _cx_self \
- _cx_memb(_clone)(_cx_self lst) { \
- _cx_self out = _cx_memb(_init)(); \
- c_foreach_3 (i, _cx_self, lst) \
- _cx_memb(_emplace_back)(&out, i_valto(i.ref)); \
- return out; \
- } \
-\
- STC_DEF void \
- _cx_memb(_drop)(_cx_self* self) { \
- while (self->last) _cx_memb(_erase_after_)(self, self->last); \
- } \
-\
- STC_DEF void \
- _cx_memb(_push_back)(_cx_self* self, i_val value) { \
- _c_clist_insert_after(self, _cx_self, self->last, value); \
- self->last = entry; \
- } \
- STC_DEF void \
- _cx_memb(_push_front)(_cx_self* self, i_val value) { \
- _c_clist_insert_after(self, _cx_self, self->last, value); \
- if (!self->last) self->last = entry; \
- } \
-\
- STC_DEF void \
- _cx_memb(_emplace_items)(_cx_self *self, const _cx_raw arr[], size_t n) { \
- for (size_t i=0; i<n; ++i) _cx_memb(_push_back)(self, i_valfrom(arr[i])); \
- } \
-\
- STC_DEF _cx_iter \
- _cx_memb(_insert_after)(_cx_self* self, _cx_iter pos, i_val value) { \
- _cx_node* node = pos.ref ? _clist_node(_cx_self, pos.ref) : NULL; \
- _c_clist_insert_after(self, _cx_self, node, value); \
- if (!node || node == self->last && pos._state == 0) self->last = entry; \
- pos.ref = &entry->value, pos._state = 0; return pos; \
- } \
-\
- STC_DEF _cx_iter \
- _cx_memb(_erase_after)(_cx_self* self, _cx_iter pos) { \
- _cx_memb(_erase_after_)(self, _clist_node(_cx_self, pos.ref)); \
- _cx_memb(_next)(&pos); return pos; \
- } \
-\
- STC_DEF _cx_iter \
- _cx_memb(_erase_range_after)(_cx_self* self, _cx_iter it1, _cx_iter it2) { \
- _cx_node* node = _clist_node(_cx_self, it1.ref), *done = it2.ref ? _clist_node(_cx_self, it2.ref) : NULL; \
- while (node && node->next != done) \
- node = _cx_memb(_erase_after_)(self, node); \
- _cx_memb(_next)(&it1); return it1; \
- } \
-\
- STC_DEF _cx_iter \
- _cx_memb(_find_before_in)(_cx_iter it1, _cx_iter it2, i_valraw val) { \
- _cx_iter i = it1; \
- for (_cx_memb(_next)(&i); i.ref != it2.ref; _cx_memb(_next)(&i)) { \
- i_valraw r = i_valto(i.ref); \
- if (i_eq((&r), (&val))) return it1; \
- it1 = i; \
- } \
- it1.ref = NULL; return it1; \
- } \
-\
- STC_DEF _cx_iter \
- _cx_memb(_find_before)(const _cx_self* self, i_valraw val) { \
- _cx_iter it = _cx_memb(_find_before_in)(_cx_memb(_before_begin)(self), _cx_memb(_end)(self), val); \
- return it; \
- } \
-\
- STC_DEF _cx_iter \
- _cx_memb(_find)(const _cx_self* self, i_valraw val) { \
- _cx_iter it = _cx_memb(_find_before_in)(_cx_memb(_before_begin)(self), _cx_memb(_end)(self), val); \
- if (it.ref != _cx_memb(_end)(self).ref) _cx_memb(_next)(&it); \
- return it; \
- } \
-\
- STC_DEF _cx_node* \
- _cx_memb(_erase_after_)(_cx_self* self, _cx_node* node) { \
- _cx_node* del = node->next, *next = del->next; \
- node->next = next; \
- if (del == next) self->last = node = NULL; \
- else if (self->last == del) self->last = node, node = NULL; \
- i_valdrop((&del->value)); c_free(del); \
- return node; \
- } \
-\
- STC_DEF size_t \
- _cx_memb(_remove)(_cx_self* self, i_valraw val) { \
- size_t n = 0; \
- _cx_node* prev = self->last, *node; \
- while (prev) { \
- node = prev->next; \
- i_valraw r = i_valto((&node->value)); \
- if (i_eq((&r), (&val))) \
- prev = _cx_memb(_erase_after_)(self, prev), ++n; \
- else \
- prev = (node == self->last ? NULL : node); \
- } \
- return n; \
- } \
-\
- STC_DEF _cx_self \
- _cx_memb(_split_after)(_cx_self* self, _cx_iter pos1, _cx_iter pos2) { \
- _cx_node *node1 = _clist_node(_cx_self, pos1.ref), *next1 = node1->next, \
- *node2 = _clist_node(_cx_self, pos2.ref); \
- node1->next = node2->next, node2->next = next1; \
- if (self->last == node2) self->last = node1; \
- _cx_self lst = {node2}; return lst; \
- } \
-\
- STC_DEF void \
- _cx_memb(_splice_after)(_cx_self* self, _cx_iter pos, _cx_self* other) { \
- if (!pos.ref) \
- self->last = other->last; \
- else if (other->last) { \
- _cx_node *node = _clist_node(_cx_self, pos.ref), *next = node->next; \
- node->next = other->last->next; \
- other->last->next = next; \
- if (node == self->last && pos._state == 0) self->last = other->last; \
- } \
- other->last = NULL; \
- } \
-\
- STC_DEF void \
- _cx_memb(_splice_after_range)(_cx_self* self, _cx_iter pos, _cx_self* other, _cx_iter pos1, _cx_iter pos2) { \
- _cx_self tmp = _cx_memb(_split_after)(other, pos1, pos2); \
- _cx_memb(_splice_after)(self, pos, &tmp); \
- } \
-\
- STC_DEF int \
- _cx_memb(_sort_cmp_)(const void* x, const void* y) { \
- i_valraw a = i_valto((&((_cx_node *) x)->value)); \
- i_valraw b = i_valto((&((_cx_node *) y)->value)); \
- return i_cmp((&a), (&b)); \
- } \
-\
- STC_DEF void \
- _cx_memb(_sort)(_cx_self* self) { \
- if (self->last) \
- self->last = (_cx_node *) _clist_mergesort((clist_VOID_node *) self->last->next, _cx_memb(_sort_cmp_)); \
- }
-
-
-#define _c_clist_insert_after(self, _cx_self, node, val) \
- _cx_node *entry = c_alloc (_cx_node); \
- if (node) entry->next = node->next, node->next = entry; \
- else entry->next = entry; \
- entry->value = val
- /* +: set self->last based on node */
-
-STC_DEF size_t
-_clist_count(const clist_VOID* self) {
- const clist_VOID_node *nd = self->last;
- if (!nd) return 0;
- size_t n = 1;
- while ((nd = nd->next) != self->last) ++n;
- return n;
-}
-
-/* Singly linked list Mergesort implementation by Simon Tatham. O(n*log n).
- * https://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
- */
-STC_DEF clist_VOID_node *
-_clist_mergesort(clist_VOID_node *list, int (*cmp)(const void*, const void*)) {
- clist_VOID_node *p, *q, *e, *tail, *oldhead;
- int insize = 1, nmerges, psize, qsize, i;
-
- while (1) {
- p = oldhead = list;
- list = tail = NULL;
- nmerges = 0;
-
- while (p) {
- ++nmerges;
- q = p, psize = 0;
- for (i = 0; i < insize; ++i) {
- ++psize;
- q = (q->next == oldhead ? NULL : q->next);
- if (!q) break;
- }
- qsize = insize;
-
- while (psize > 0 || (qsize > 0 && q)) {
- if (psize == 0) {
- e = q, q = q->next, --qsize;
- if (q == oldhead) q = NULL;
- } else if (qsize == 0 || !q) {
- e = p, p = p->next, --psize;
- if (p == oldhead) p = NULL;
- } else if (cmp(p, q) <= 0) {
- e = p, p = p->next, --psize;
- if (p == oldhead) p = NULL;
- } else {
- e = q, q = q->next, --qsize;
- if (q == oldhead) q = NULL;
- }
- if (tail) tail->next = e; else list = e;
- tail = e;
- }
- p = q;
- }
- tail->next = list;
-
- if (nmerges <= 1)
- return tail;
-
- insize *= 2;
- }
-}
-
-#else
-#define _c_implement_clist(_cx_self, i_val, i_cmp, i_valdrop, i_valfrom, i_valto, i_valraw)
-#endif
-
-#endif
diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h
index cb976801..6794bec3 100644
--- a/include/stc/alt/csmap.h
+++ b/include/stc/alt/csmap.h
@@ -197,7 +197,7 @@ int main(void) {
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
_c_aatree_types(csmap_SENTINEL, csmap_, int, int, i_size);
_c_aatree_complete_types(csmap_SENTINEL, csmap_);
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h
index b366cd35..3dc72178 100644
--- a/include/stc/alt/cstr.h
+++ b/include/stc/alt/cstr.h
@@ -187,7 +187,7 @@ STC_INLINE uint64_t cstr_hash(const cstr *self) {
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
#ifndef _i_static
static cstr_priv _cstr_nullrep = {0, 0, {0}};
diff --git a/include/stc/carr2.h b/include/stc/carr2.h
index a9e9d9f8..2910a086 100644
--- a/include/stc/carr2.h
+++ b/include/stc/carr2.h
@@ -98,7 +98,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it)
{ ++it->ref; }
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
STC_DEF _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, _cx_value* block) {
_cx_self _arr = {c_alloc_n(_cx_value*, xdim), xdim, ydim};
diff --git a/include/stc/carr3.h b/include/stc/carr3.h
index 2b466b13..4c380161 100644
--- a/include/stc/carr3.h
+++ b/include/stc/carr3.h
@@ -101,7 +101,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it)
{ ++it->ref; }
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
STC_DEF _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, size_t zdim, _cx_value* block) {
_cx_self _arr = {c_alloc_n(_cx_value**, xdim*(ydim + 1)), xdim, ydim, zdim};
diff --git a/include/stc/cbits.h b/include/stc/cbits.h
index 8d030e25..8964c275 100644
--- a/include/stc/cbits.h
+++ b/include/stc/cbits.h
@@ -165,7 +165,7 @@ STC_INLINE void cbits_xor(cbits *self, cbits other) {
}
#endif
-#if defined(_i_implement)
+#if defined(i_implement)
STC_DEF cbits* cbits_copy(cbits* self, cbits other) {
if (self->data64 == other.data64) return self;
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 2b40557a..6e4d9dff 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -102,7 +102,6 @@
#define c_no_cmp (1<<3)
#define c_static (1<<4)
#define c_header (1<<5)
-#define c_implement (1<<6)
/* Generic algorithms */
@@ -234,10 +233,10 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, size_t slen, cons
#undef STC_API
#undef STC_DEF
#undef _i_static
-#undef _i_implement
+#undef i_implement
-#if !c_option(c_static) && (c_option(c_header) || c_option(c_implement) || \
- defined(STC_HEADER) || defined(STC_IMPLEMENTATION))
+#if !c_option(c_static) && (c_option(c_header) || defined(STC_HEADER) || \
+ defined(STC_IMPLEMENT) || defined(STC_IMPLEMENTATION))
# define STC_API extern
# define STC_DEF
#else
@@ -245,6 +244,6 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, size_t slen, cons
# define STC_API static inline
# define STC_DEF static inline
#endif
-#if c_option(c_implement) || defined(STC_IMPLEMENTATION) || defined(_i_static)
-# define _i_implement
+#if defined(_i_static) || defined(STC_IMPLEMENT) || defined(STC_IMPLEMENTATION)
+# define i_implement
#endif
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 2c0df8c3..de4221ef 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -200,7 +200,7 @@ _cx_memb(_sort)(_cx_self* self) {
#endif // _i_queue
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
#ifndef CDEQ_H_INCLUDED
static struct cdeq_rep _cdeq_sentinel = {0, 0};
diff --git a/include/stc/clist.h b/include/stc/clist.h
index 33aa6feb..0e467737 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -188,7 +188,7 @@ _cx_memb(_get_mut)(_cx_self* self, i_keyraw val) {
#endif
// -------------------------- IMPLEMENTATION -------------------------
-#if defined(_i_implement)
+#if defined(i_implement)
#if !defined _i_no_clone
STC_DEF _cx_self
@@ -397,6 +397,6 @@ _clist_mergesort(clist_VOID_node *list, int (*cmp)(const clist_VOID_node*, const
}
#endif // !c_no_cmp
#endif // !CLIST_H_INCLUDED
-#endif // _i_implement
+#endif // i_implement
#define CLIST_H_INCLUDED
#include "template.h"
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 25356e16..5f1ae3f2 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -237,7 +237,7 @@ _cx_memb(_erase_at)(_cx_self* self, _cx_iter it) {
}
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
#ifndef CMAP_H_INCLUDED
STC_INLINE size_t fastrange_size_t(uint64_t x, uint64_t n)
@@ -336,6 +336,14 @@ _cx_memb(_clone)(_cx_self m) {
if (*hx) *dst = _cx_memb(_value_clone)(*e);
return clone;
}
+
+STC_DEF _cx_self
+_cx_memb(_clone2)(_cx_self m) {
+ _cx_self clone = _cx_memb(_with_capacity)(m.size);
+ c_foreach (i, _cx_self, m)
+ _cx_memb(_push)(&clone, _cx_memb(_value_clone)(*i.ref));
+ return clone;
+}
#endif
STC_DEF bool
@@ -388,7 +396,7 @@ _cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) {
--self->size;
}
-#endif // _i_implement
+#endif // i_implement
#undef _i_isset
#undef _i_ismap
#undef _i_ishash
diff --git a/include/stc/cpque.h b/include/stc/cpque.h
index 4b330707..cb4b6e70 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -105,7 +105,7 @@ STC_INLINE void _cx_memb(_emplace)(_cx_self* self, _cx_raw raw)
#endif // !_i_no_clone
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
STC_DEF void
_cx_memb(_sift_down_)(_cx_value* arr, const size_t idx, const size_t n) {
diff --git a/include/stc/crandom.h b/include/stc/crandom.h
index 5a68657e..a9877b50 100644
--- a/include/stc/crandom.h
+++ b/include/stc/crandom.h
@@ -129,7 +129,7 @@ STC_INLINE stc64_normalf_t stc64_normalf_init(double mean, double stddev)
{ return stc64_normalf_new(mean, stddev); }
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
/* Global random() */
static stc64_t stc64_global = {{
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index 25f66d79..009f39b3 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -199,7 +199,7 @@ _cx_memb(_advance)(_cx_iter it, size_t n) {
}
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
#ifndef CSMAP_H_INCLUDED
static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0};
@@ -533,7 +533,7 @@ _cx_memb(_drop)(_cx_self* self) {
}
}
-#endif // _i_implement
+#endif // i_implement
#undef _i_isset
#undef _i_ismap
#undef _i_keyref
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index fa791815..20b50ee9 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -275,7 +275,7 @@ STC_INLINE uint64_t cstr_hash(const cstr *self) {
}
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
STC_DEF char* _cstr_internal_move(cstr* self, const size_t pos1, const size_t pos2) {
cstr_rep_t r = cstr_rep(self);
@@ -473,7 +473,7 @@ STC_DEF int cstr_printf(cstr* self, const char* fmt, ...) {
return n;
}
-#endif // _i_implement
+#endif // i_implement
#if defined __GNUC__ && !defined __clang__
# pragma GCC diagnostic pop
#endif
diff --git a/include/stc/csview.h b/include/stc/csview.h
index dd8559b5..d56781a6 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -132,7 +132,7 @@ STC_INLINE uint64_t csview_hash(const csview *self)
{ return c_fasthash(self->str, self->size); }
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
STC_DEF csview
csview_substr(csview sv, intptr_t pos, size_t n) {
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 54b38222..7b032ff0 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -252,7 +252,7 @@ _cx_memb(_sort)(_cx_self* self) {
}
#endif // !c_no_cmp
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if defined(_i_implement)
+#if defined(i_implement)
#ifndef CVEC_H_INCLUDED
static struct cvec_rep _cvec_sentinel = {0, 0};
@@ -419,6 +419,6 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) {
return i_cmp((&rx), (&ry));
}
#endif // !c_no_cmp
-#endif // _i_implement
+#endif // i_implement
#define CVEC_H_INCLUDED
#include "template.h"
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index b8b4f27f..9a1493b6 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -57,7 +57,7 @@ STC_INLINE size_t utf8_codep_size(const char *s) {
}
// --------------------------- IMPLEMENTATION ---------------------------------
-#ifdef _i_implement
+#ifdef i_implement
// https://news.ycombinator.com/item?id=15423674
// https://gist.github.com/s4y/344a355f8c1f99c6a4cb2347ec4323cc