Explorar el Código

arraylsits can now reserve

banana-cakes
Felix Brendel hace 6 años
padre
commit
7d8eabf479
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. +7
    -0
      arraylist.hpp

+ 7
- 0
arraylist.hpp Ver fichero

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


Cargando…
Cancelar
Guardar