diff options
| author | Tyge Lovset <[email protected]> | 2022-04-02 00:14:17 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2022-04-02 00:32:00 +0200 |
| commit | d1660bb47cbf3fc0a7066ef1472f2d3bdfeb92b3 (patch) | |
| tree | 2e9e55277432c1008cde08ac2c714d898c098fee | |
| parent | b707e18ae93c60f2b659bad39f1daf54604445f7 (diff) | |
| download | STC-modified-d1660bb47cbf3fc0a7066ef1472f2d3bdfeb92b3.tar.gz STC-modified-d1660bb47cbf3fc0a7066ef1472f2d3bdfeb92b3.zip | |
Internal refactoring/macro rename.
| -rw-r--r-- | include/stc/carc.h | 2 | ||||
| -rw-r--r-- | include/stc/carr2.h | 4 | ||||
| -rw-r--r-- | include/stc/carr3.h | 5 | ||||
| -rw-r--r-- | include/stc/cbox.h | 2 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 26 | ||||
| -rw-r--r-- | include/stc/clist.h | 4 | ||||
| -rw-r--r-- | include/stc/cmap.h | 12 | ||||
| -rw-r--r-- | include/stc/cpque.h | 4 | ||||
| -rw-r--r-- | include/stc/csmap.h | 10 | ||||
| -rw-r--r-- | include/stc/cstack.h | 4 | ||||
| -rw-r--r-- | include/stc/cvec.h | 8 | ||||
| -rw-r--r-- | include/stc/template.h | 11 |
12 files changed, 43 insertions, 49 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h index a0c4ba77..a133b577 100644 --- a/include/stc/carc.h +++ b/include/stc/carc.h @@ -143,7 +143,7 @@ _cx_memb(_reset_from)(_cx_self* self, i_val val) { *self = _cx_memb(_from)(val);
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_INLINE _cx_self
_cx_memb(_new)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
#endif
diff --git a/include/stc/carr2.h b/include/stc/carr2.h index 2205356a..a9c19175 100644 --- a/include/stc/carr2.h +++ b/include/stc/carr2.h @@ -65,7 +65,7 @@ STC_API _cx_self _cx_memb(_with_values)(size_t xdim, size_t ydim, i_val value) STC_API _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, _cx_value* storage); STC_API _cx_value* _cx_memb(_release)(_cx_self* self); STC_API void _cx_memb(_drop)(_cx_self* self); -#if !defined _i_no_from +#if !defined _i_no_clone STC_API _cx_self _cx_memb(_clone)(_cx_self src); STC_API void _cx_memb(_copy)(_cx_self *self, _cx_self other); #endif @@ -114,7 +114,7 @@ STC_DEF _cx_self _cx_memb(_with_values)(size_t xdim, size_t ydim, i_val value) { return _arr; } -#if !defined _i_no_from +#if !defined _i_no_clone STC_DEF _cx_self _cx_memb(_clone)(_cx_self src) { _cx_self _arr = _cx_memb(_init)(src.xdim, src.ydim); diff --git a/include/stc/carr3.h b/include/stc/carr3.h index c6c82019..c215bd80 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -67,12 +67,11 @@ STC_API _cx_self _cx_memb(_with_values)(size_t xdim, size_t ydim, size_t zdim, STC_API _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, size_t zdim, _cx_value* storage); STC_API _cx_value* _cx_memb(_release)(_cx_self* self); STC_API void _cx_memb(_drop)(_cx_self* self); -#if !defined _i_no_from +#if !defined _i_no_clone STC_API _cx_self _cx_memb(_clone)(_cx_self src); STC_API void _cx_memb(_copy)(_cx_self *self, _cx_self other); #endif - STC_INLINE _cx_self _cx_memb(_init)(size_t xdim, size_t ydim, size_t zdim) { return _cx_memb(_with_storage)(xdim, ydim, zdim, c_alloc_n(_cx_value, xdim*ydim*zdim)); } @@ -120,7 +119,7 @@ STC_DEF _cx_self _cx_memb(_with_values)(size_t xdim, size_t ydim, size_t zdim, i return _arr; } -#if !defined _i_no_from +#if !defined _i_no_clone STC_DEF _cx_self _cx_memb(_clone)(_cx_self src) { _cx_self _arr = _cx_memb(_init)(src.xdim, src.ydim, src.zdim); diff --git a/include/stc/cbox.h b/include/stc/cbox.h index ee2e0a45..6d06c052 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -117,7 +117,7 @@ _cx_memb(_reset_from)(_cx_self* self, i_val val) { else self->get = c_new(i_val, val);
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_INLINE _cx_self
_cx_memb(_new)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 410db96f..f9de31d2 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -48,13 +48,13 @@ STC_API void _cx_memb(_clear)(_cx_self* self); STC_API void _cx_memb(_drop)(_cx_self* self);
STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value);
STC_API void _cx_memb(_shrink_to_fit)(_cx_self *self);
-#ifndef _i_queue
-#if !defined _i_no_from
+#if !defined _i_queue
+#if !defined _i_no_clone
STC_API _cx_iter _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos,
const _cx_value* p1, const _cx_value* p2);
STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos,
const _cx_raw* p1, const _cx_raw* p2);
-#endif // _c_no_from
+#endif // !_i_no_clone
#if !c_option(c_no_cmp)
STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, i_valraw raw);
@@ -66,7 +66,7 @@ STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos const _cx_value* p1, const _cx_value* p2);
#endif // !_i_queue
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw)
@@ -98,7 +98,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it) { ++it->ref; } STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs)
{ it.ref += offs; return it; }
-#ifndef _i_queue
+#if !defined _i_queue
STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) {
_cx_value* p = &self->data[--cdeq_rep_(self)->size];
@@ -140,7 +140,7 @@ _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2) { return _cx_memb(_erase_range_p)(self, it1.ref, it2.ref);
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_INLINE _cx_iter
_cx_memb(_emplace_range)(_cx_self* self, _cx_iter it, _cx_iter it1, _cx_iter it2) {
@@ -163,7 +163,7 @@ STC_INLINE _cx_iter _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_valraw raw) {
return _cx_memb(_emplace_range_p)(self, it.ref, &raw, &raw + 1);
}
-#endif // _c_no_from
+#endif // !_i_no_clone
#if !c_option(c_no_cmp)
@@ -264,11 +264,11 @@ _cx_memb(_expand_right_half_)(_cx_self* self, const size_t idx, const size_t n) if (!_cx_memb(_realloc_)(self, n)) return false;
memmove(self->data + idx + n, self->data + idx, (sz - idx)*sizeof(i_val));
} else {
-#ifdef _i_queue
- const size_t pos = 0;
-#else
+#if !defined _i_queue
const size_t unused = cap - (sz + n);
const size_t pos = (nfront*2 < unused) ? nfront : unused/2;
+#else
+ const size_t pos = 0;
#endif
memmove(self->_base + pos, self->data, idx*sizeof(i_val));
memmove(self->data + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_val));
@@ -310,7 +310,7 @@ _cx_memb(_clone)(_cx_self cx) { }
#endif
-#ifndef _i_queue
+#if !defined _i_queue
static void
_cx_memb(_expand_left_half_)(_cx_self* self, const size_t idx, const size_t n) {
@@ -371,7 +371,7 @@ _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) { return c_make(_cx_iter){p1};
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_DEF _cx_iter
_cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, const _cx_raw* p2) {
pos = _cx_memb(_insert_space_)(self, pos, p2 - p1);
@@ -388,7 +388,7 @@ _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos, for (; p1 != p2; ++p1) *pos++ = i_valfrom(i_valto(p1));
return it;
}
-#endif // !_i_no_from
+#endif // !_i_no_clone
#if !c_option(c_no_cmp)
diff --git a/include/stc/clist.h b/include/stc/clist.h index 70620534..e035d830 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -106,7 +106,7 @@ STC_API _cx_iter _cx_memb(_splice)(_cx_self* self, _cx_iter it, _cx_self* STC_API _cx_self _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2);
STC_API _cx_node* _cx_memb(_erase_after_)(_cx_self* self, _cx_node* node);
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
STC_INLINE i_val _cx_memb(_value_clone)(i_val val)
{ return i_valfrom(i_valto(&val)); }
@@ -185,7 +185,7 @@ _cx_memb(_get_mut)(_cx_self* self, i_valraw val) { // -------------------------- IMPLEMENTATION -------------------------
#if defined(_i_implement)
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self cx) {
_cx_self out = _cx_memb(_init)();
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index bbe021a7..9bc4d621 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -87,7 +87,7 @@ typedef _i_SET_ONLY( i_keyraw ) _cx_raw;
STC_API _cx_self _cx_memb(_with_capacity)(size_t cap);
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self map);
#endif
STC_API void _cx_memb(_drop)(_cx_self* self);
@@ -110,7 +110,7 @@ STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) { return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; }
#ifndef _i_isset
- #if !defined _i_no_from
+ #if !defined _i_no_clone
STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped);
#endif
STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key _key, i_val _mapped);
@@ -128,7 +128,7 @@ STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) }
#endif
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) {
if (self->table == other.table) return;
_cx_memb(_drop)(self); *self = _cx_memb(_clone)(other);
@@ -150,7 +150,7 @@ _cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped) }
return _res;
}
-#endif // !_i_no_from
+#endif // !_i_no_clone
STC_INLINE _cx_raw
_cx_memb(_value_toraw)(_cx_value* val) {
@@ -272,7 +272,7 @@ STC_DEF void _cx_memb(_clear)(_cx_self* self) { _res.ref->second = _mapped; return _res;
}
- #if !defined _i_no_from
+ #if !defined _i_no_clone
STC_DEF _cx_result
_cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped) {
_cx_result _res = _cx_memb(_insert_entry_)(self, rkey);
@@ -313,7 +313,7 @@ _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey) { return res;
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self m) {
_cx_self clone = {
diff --git a/include/stc/cpque.h b/include/stc/cpque.h index d8480a17..45a8828f 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -88,7 +88,7 @@ STC_INLINE _cx_value* _cx_memb(_top)(const _cx_self* self) STC_INLINE void _cx_memb(_pop)(_cx_self* self)
{ _cx_memb(_erase_at)(self, 0); }
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self q);
STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) {
@@ -122,7 +122,7 @@ _cx_memb(_make_heap)(_cx_self* self) { _cx_memb(_sift_down_)(arr, k, n);
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_DEF _cx_self _cx_memb(_clone)(_cx_self q) {
_cx_self out = _cx_memb(_with_capacity)(q.size);
for (; out.size < out.capacity; ++out.size, ++q.data)
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index 49110221..9f8a3455 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -93,7 +93,7 @@ typedef _i_SET_ONLY( i_keyraw ) _i_MAP_ONLY( struct { i_keyraw first; i_valraw second; } )
_cx_raw;
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self tree);
STC_API void _cx_memb(_copy)(_cx_self *self, _cx_self other);
STC_API _cx_value _cx_memb(_value_clone)(_cx_value _val);
@@ -154,7 +154,7 @@ _cx_memb(_value_drop)(_cx_value* val) { }
#ifndef _i_isset
- #if !defined _i_no_from
+ #if !defined _i_no_clone
STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped);
#endif
STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key key, i_val mapped);
@@ -275,7 +275,7 @@ _cx_memb(_insert)(_cx_self* self, i_key key _i_MAP_ONLY(, i_val mapped)) { res.ref->second = mapped; return res;
}
- #if !defined _i_no_from
+ #if !defined _i_no_clone
STC_DEF _cx_result
_cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped) {
_cx_result res = _cx_memb(_insert_entry_)(self, rkey);
@@ -458,7 +458,7 @@ _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2) { }
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_DEF void
_cx_memb(_copy)(_cx_self *self, _cx_self other) {
if (self->nodes == other.nodes) return;
@@ -500,7 +500,7 @@ _cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped) }
return res;
}
-#endif // !_i_no_from
+#endif // !_i_no_clone
static void
_cx_memb(_drop_r_)(_cx_node* d, _cx_size tn) {
diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 29b13c90..1d2b259d 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -98,7 +98,7 @@ STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t idx)
{ assert(idx < self->size); return self->data + idx; }
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw)
{ return _cx_memb(_push)(self, i_valfrom(raw)); }
STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, _cx_raw raw)
@@ -119,7 +119,7 @@ STC_INLINE i_val _cx_memb(_value_clone)(_cx_value val) { return i_valfrom(i_valto(&val)); }
STC_INLINE i_valraw _cx_memb(_value_toraw)(_cx_value* val)
{ return i_valto(val); }
-#endif // !_i_no_from
+#endif // !_i_no_clone
STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self)
{ return c_make(_cx_iter){self->data}; }
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 7ba9fb85..ec8e9164 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -92,7 +92,7 @@ STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw STC_API _cx_iter _cx_memb(_bsearch_in)(_cx_iter it1, _cx_iter it2, i_valraw raw);
#endif
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
STC_API _cx_iter _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos,
const _cx_value* p1, const _cx_value* p2);
@@ -122,7 +122,7 @@ STC_INLINE _cx_iter _cx_memb(_emplace_range)(_cx_self* self, _cx_iter it, _cx_iter it1, _cx_iter it2) {
return _cx_memb(_clone_range_p)(self, it.ref, it1.ref, it2.ref);
}
-#endif // !_c_no_from
+#endif // !_i_no_clone
STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cvec_rep_(&cx)->size; }
STC_INLINE size_t _cx_memb(_capacity)(_cx_self cx) { return cvec_rep_(&cx)->cap; }
@@ -330,7 +330,7 @@ _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) { return c_make(_cx_iter){.ref = p1};
}
-#if !defined _i_no_from
+#if !defined _i_no_clone
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self cx) {
@@ -357,7 +357,7 @@ _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, for (; p1 != p2; ++p1) *pos++ = i_valfrom(*p1);
return it;
}
-#endif // !_i_no_from
+#endif // !_i_no_clone
#if !c_option(c_no_cmp)
diff --git a/include/stc/template.h b/include/stc/template.h index da6f1d9c..593a9313 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -158,9 +158,7 @@ #define i_tag i_key
#endif
#if !defined i_keyfrom && defined i_keydrop
- #define _i_no_from
- #elif defined i_keyfrom && !defined i_keydrop
- #define _i_no_drop
+ #define _i_no_clone
#endif
#ifndef i_keyfrom
#define i_keyfrom c_default_from
@@ -182,9 +180,7 @@ #define i_tag i_val
#endif
#if (!defined i_valfrom && defined i_valdrop) || c_option(c_no_clone)
- #define _i_no_from
-#elif defined i_valfrom && !defined i_valdrop
- #define _i_no_drop
+ #define _i_no_clone
#endif
#ifndef i_valfrom
#define i_valfrom c_default_from
@@ -242,7 +238,6 @@ #undef i_keydrop
#undef _i_prefix
-#undef _i_no_from
-#undef _i_no_drop
+#undef _i_no_clone
#undef _i_template
#endif
|
