Changeset a6fe3de for src/libcfa/containers/vector
- Timestamp:
- Sep 19, 2016, 5:23:45 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:
- db46512
- Parents:
- 89e6ffc (diff), bd34fc87 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/vector
r89e6ffc ra6fe3de 20 20 } 21 21 22 #define DESTROY(x)23 24 22 //------------------------------------------------------------------------------ 25 23 //Declaration 26 24 trait allocator_c(otype T, otype allocator_t) 27 25 { 28 void ctor(allocator_t* const); 29 void dtor(allocator_t* const); 30 void realloc_storage(allocator_t* const, size_t); 31 T* data(allocator_t* const); 26 void realloc_storage(allocator_t*, size_t); 27 T* data(allocator_t*); 32 28 }; 29 30 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 31 struct vector; 32 33 //------------------------------------------------------------------------------ 34 //Initialization 35 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 36 void ?{}(vector(T, allocator_t)* this); 37 38 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 39 void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs); 40 41 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 42 vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs); 43 44 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 45 void ^?{}(vector(T, allocator_t)* this); 33 46 34 47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) … … 40 53 41 54 //------------------------------------------------------------------------------ 42 //Initialization43 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))44 void ctor(vector(T, allocator_t) *const this);45 46 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))47 void dtor(vector(T, allocator_t) *const this);48 49 //------------------------------------------------------------------------------50 55 //Capacity 51 56 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 52 static inline bool empty(vector(T, allocator_t) *constthis)57 static inline bool empty(vector(T, allocator_t)* this) 53 58 { 54 59 return this->size == 0; … … 56 61 57 62 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 58 static inline size_t size(vector(T, allocator_t) *constthis)63 static inline size_t size(vector(T, allocator_t)* this) 59 64 { 60 65 return this->size; … … 62 67 63 68 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 64 static inline void reserve(vector(T, allocator_t) *constthis, size_t size)69 static inline void reserve(vector(T, allocator_t)* this, size_t size) 65 70 { 66 71 realloc_storage(&this->storage, this->size+1); … … 70 75 //Element access 71 76 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 72 static inline T at(vector(T, allocator_t) *constthis, size_t index)77 static inline T at(vector(T, allocator_t)* this, size_t index) 73 78 { 74 79 return data(&this->storage)[index]; … … 76 81 77 82 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 78 static inline T ?[?](vector(T, allocator_t) *constthis, size_t index)83 static inline T ?[?](vector(T, allocator_t)* this, size_t index) 79 84 { 80 85 return data(&this->storage)[index]; … … 82 87 83 88 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 84 static inline T front(vector(T, allocator_t) *constthis)89 static inline T front(vector(T, allocator_t)* this) 85 90 { 86 91 return data(&this->storage)[0]; … … 88 93 89 94 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 90 static inline T back(vector(T, allocator_t) *constthis)95 static inline T back(vector(T, allocator_t)* this) 91 96 { 92 97 return data(&this->storage)[this->size - 1]; … … 96 101 //Modifiers 97 102 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 98 void push_back(vector(T, allocator_t) *constthis, T value);103 void push_back(vector(T, allocator_t)* this, T value); 99 104 100 105 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 101 void pop_back(vector(T, allocator_t) *constthis);106 void pop_back(vector(T, allocator_t)* this); 102 107 103 108 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 104 void clear(vector(T, allocator_t) *constthis);109 void clear(vector(T, allocator_t)* this); 105 110 106 111 //------------------------------------------------------------------------------ 107 112 //Iterators 108 113 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 109 static inline T* begin(vector(T, allocator_t) *constthis)114 static inline T* begin(vector(T, allocator_t)* this) 110 115 { 111 116 return data(&this->storage); … … 113 118 114 119 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 115 static inline const T* cbegin(const vector(T, allocator_t) *constthis)120 static inline const T* cbegin(const vector(T, allocator_t)* this) 116 121 { 117 122 return data(&this->storage); … … 119 124 120 125 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 121 static inline T* end(vector(T, allocator_t) *constthis)126 static inline T* end(vector(T, allocator_t)* this) 122 127 { 123 128 return data(&this->storage) + this->size; … … 125 130 126 131 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 127 static inline const T* cend(const vector(T, allocator_t) *constthis)132 static inline const T* cend(const vector(T, allocator_t)* this) 128 133 { 129 134 return data(&this->storage) + this->size; … … 140 145 141 146 forall(otype T) 142 void ctor(heap_allocator(T) *constthis);147 void ?{}(heap_allocator(T)* this); 143 148 144 149 forall(otype T) 145 void dtor(heap_allocator(T) *const this);150 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs); 146 151 147 152 forall(otype T) 148 void realloc_storage(heap_allocator(T) *const this, size_t size);153 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs); 149 154 150 155 forall(otype T) 151 static inline T* data(heap_allocator(T) *const this) 156 void ^?{}(heap_allocator(T)* this); 157 158 forall(otype T) 159 void realloc_storage(heap_allocator(T)* this, size_t size); 160 161 forall(otype T) 162 static inline T* data(heap_allocator(T)* this) 152 163 { 153 164 return this->storage;
Note: See TracChangeset
for help on using the changeset viewer.