arraylsits can now reserve

This commit is contained in:
Felix Brendel
2020-01-08 11:01:18 +01:00
parent 635af49d52
commit 7d8eabf479
+7
View File
@@ -51,6 +51,13 @@ struct Array_List {
next_index++; next_index++;
} }
void reserve(unsigned int count) {
if (next_index+count <= length) {
length *= 2;
data = (type*)realloc(data, length * sizeof(type));
}
}
type& operator[](int index) { type& operator[](int index) {
return data[index]; return data[index];
} }