4 #define VECTOR_DEFCAP 8
6 template<typename type>
9 Vector(uint _capacity = VECTOR_DEFCAP) :
12 array((type *) ourmalloc(sizeof(type) * _capacity)) {
15 Vector(uint _capacity, type *_array) :
18 array((type *) ourmalloc(sizeof(type) * _capacity)) {
19 memcpy(array, _array, capacity * sizeof(type));
27 return array[size - 1];
30 void setSize(uint _size) {
34 } else if (_size > capacity) {
35 array = (type *)ourrealloc(array, _size * sizeof(type));
38 bzero(&array[size], (_size - size) * sizeof(type));
42 void push(type item) {
43 if (size >= capacity) {
44 uint newcap = capacity << 1;
45 array = (type *)ourrealloc(array, newcap * sizeof(type));
51 type get(uint index) const {
55 void setExpand(uint index, type item) {
61 void set(uint index, type item) {
65 uint getSize() const {