Преглед на файлове

arraylsits can now reserve

banana-cakes
Felix Brendel преди 6 години
родител
ревизия
7d8eabf479
променени са 1 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. +7
    -0
      arraylist.hpp

+ 7
- 0
arraylist.hpp Целия файл

@@ -51,6 +51,13 @@ struct Array_List {
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) {
return data[index];
}


Зареждане…
Отказ
Запис