瀏覽代碼

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];
}


Loading…
取消
儲存