Polymorphic procedure, with passed in compile time type but without removing the type in params etc.

This commit is contained in:
Krzosa Karol
2023-04-01 19:40:12 +02:00
parent 3d438645a0
commit 7bf3e107bb
8 changed files with 158 additions and 80 deletions

View File

@@ -54,6 +54,24 @@ struct Array {
}
}
#if 0
void insert(T item, int index) {
if (index == len) {
add(item);
return;
}
assert(index < len);
assert(index >= 0);
grow(1);
int right_len = len - index;
memmove(data + index + 1, data + index, sizeof(T) * right_len);
data[index] = item;
len += 1;
}
#endif
void add(T item) {
grow(1);
data[len++] = item;
@@ -113,14 +131,6 @@ struct Array {
}
};
template <class T>
CORE_Static Array<T>
array_make(Allocator *a, S64 size = 16) {
Array<T> result = {};
result.init(a, size);
return result;
}
//-----------------------------------------------------------------------------
// Map
//-----------------------------------------------------------------------------