aboutsummaryrefslogtreecommitdiff
path: root/src/array.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-09-13 00:58:39 +0100
committergingerBill <bill@gingerbill.org>2021-09-13 00:58:39 +0100
commitfb8fa5217d4a5081dacc0a74a786cd2efc964fdb (patch)
tree49724edef53493c6630aa8b2ae91ea3ad57621a4 /src/array.cpp
parent6585601765c24523e43ca3a158abc61d373168db (diff)
Begin minimize `Type` size by replacing `Array` with `Slice` etc
Diffstat (limited to 'src/array.cpp')
-rw-r--r--src/array.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/array.cpp b/src/array.cpp
index 90d85563c..521fa91e2 100644
--- a/src/array.cpp
+++ b/src/array.cpp
@@ -151,6 +151,19 @@ void slice_copy(Slice<T> *slice, Slice<T> const &data, isize offset, isize count
template <typename T>
+gb_inline Slice<T> slice(Slice<T> const &array, isize lo, isize hi) {
+ GB_ASSERT(0 <= lo && lo <= hi && hi <= array.count);
+ Slice<T> out = {};
+ isize len = hi-lo;
+ if (len > 0) {
+ out.data = array.data+lo;
+ out.count = len;
+ }
+ return out;
+}
+
+
+template <typename T>
void slice_ordered_remove(Slice<T> *array, isize index) {
GB_ASSERT(0 <= index && index < array->count);