Go to the documentation of this file.00001
00006 #include<my_lib/int_vector_t>
00007 #include<cstdlib>
00008
00009 namespace my_lib {
00010
00011 int_vector_t::int_vector_t (unsigned size) :
00012 _size(size), _capacity(size) {
00013 _content = (int*) std::calloc(size, sizeof(int));
00014 }
00015
00016 int_vector_t::~int_vector_t () {
00017 std::free(_content);
00018 }
00019
00020 void int_vector_t::resize(unsigned new_size) {
00021 reserve(new_size);
00022 _size = new_size;
00023 }
00024
00025 void int_vector_t::reserve(unsigned new_capacity) {
00026 if(new_capacity > _capacity) {
00027 _capacity = new_capacity;
00028 _content = (int*)realloc(_content, sizeof(int)*new_capacity);
00029 }
00030 }
00031
00032 }