浏览代码

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


正在加载...
取消
保存