5 #define VECTOR_DEFCAP 8
7 template<typename type>
10 Vector(uint _capacity = VECTOR_DEFCAP) :
13 array((type *) ourmalloc(sizeof(type) * _capacity)) {
16 Vector(uint _capacity, type *_array) :
19 array((type *) ourmalloc(sizeof(type) * _capacity)) {
20 memcpy(array, _array, capacity * sizeof(type));
28 return array[size - 1];
31 void setSize(uint _size) {
35 } else if (_size > capacity) {
36 array = (type *)ourrealloc(array, _size * sizeof(type));
39 bzero(&array[size], (_size - size) * sizeof(type));
43 void push(type item) {
44 if (size >= capacity) {
45 uint newcap = capacity << 1;
46 array = (type *)ourrealloc(array, newcap * sizeof(type));
52 type get(uint index) {
56 void setExpand(uint index, type item) {
62 void set(uint index, type item) {