Changeset aca65621 for src/libcfa/containers/vector.c
- Timestamp:
- Jul 12, 2017, 4:40:02 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0698aa1
- Parents:
- 469f709
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/vector.c
r469f709 raca65621 24 24 //Initialization 25 25 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 26 void ?{}(vector(T, allocator_t) *this)26 void ?{}(vector(T, allocator_t)& this) 27 27 { 28 ( &this->storage){};29 this ->size = 0;28 (this.storage){}; 29 this.size = 0; 30 30 } 31 31 32 32 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 33 void ?{}(vector(T, allocator_t) *this, vector(T, allocator_t) rhs)33 void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs) 34 34 { 35 ( &this->storage){ rhs.storage };36 copy_internal( this, &rhs);35 (this.storage){ rhs.storage }; 36 copy_internal(&this, &rhs); 37 37 } 38 38 … … 46 46 47 47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 48 void ^?{}(vector(T, allocator_t) *this)48 void ^?{}(vector(T, allocator_t)& this) 49 49 { 50 clear( this);51 ^( &this->storage){};50 clear(&this); 51 ^(this.storage){}; 52 52 } 53 53 … … 66 66 { 67 67 this->size--; 68 ^( &data(&this->storage)[this->size]){};68 ^(data(&this->storage)[this->size]){}; 69 69 } 70 70 … … 74 74 for(size_t i = 0; i < this->size; i++) 75 75 { 76 ^( &data(&this->storage)[this->size]){};76 ^(data(&this->storage)[this->size]){}; 77 77 } 78 78 this->size = 0; … … 87 87 this->size = other->size; 88 88 for(size_t i = 0; i < this->size; i++) { 89 ( &data(&this->storage)[this->size]){ data(&other->storage)[other->size] };89 (data(&this->storage)[this->size]){ data(&other->storage)[other->size] }; 90 90 } 91 91 } … … 94 94 //Allocator 95 95 forall(otype T) 96 void ?{}(heap_allocator(T) *this)96 void ?{}(heap_allocator(T)& this) 97 97 { 98 this ->storage = 0;99 this ->capacity = 0;98 this.storage = 0; 99 this.capacity = 0; 100 100 } 101 101 102 102 forall(otype T) 103 void ?{}(heap_allocator(T) *this, heap_allocator(T) rhs)103 void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs) 104 104 { 105 this ->capacity = rhs.capacity;106 this ->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));105 this.capacity = rhs.capacity; 106 this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T)); 107 107 } 108 108 109 109 forall(otype T) 110 heap_allocator(T) ?=?(heap_allocator(T) *this, heap_allocator(T) rhs)110 heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs) 111 111 { 112 this ->capacity = rhs.capacity;113 this ->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));114 return *this;112 this.capacity = rhs.capacity; 113 this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T)); 114 return this; 115 115 } 116 116 117 117 forall(otype T) 118 void ^?{}(heap_allocator(T) *this)118 void ^?{}(heap_allocator(T)& this) 119 119 { 120 free(this ->storage);120 free(this.storage); 121 121 } 122 122
Note: See TracChangeset
for help on using the changeset viewer.