Changes in src/libcfa/containers/vector [bd34fc87:60aa49a7]
- File:
-
- 1 edited
-
src/libcfa/containers/vector (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/vector
rbd34fc87 r60aa49a7 20 20 } 21 21 22 #define DESTROY(x) 23 22 24 //------------------------------------------------------------------------------ 23 25 //Declaration 24 26 trait allocator_c(otype T, otype allocator_t) 25 27 { 26 void realloc_storage(allocator_t*, size_t); 27 T* data(allocator_t*); 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); 28 32 }; 29 30 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))31 struct vector;32 33 //------------------------------------------------------------------------------34 //Initialization35 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);46 33 47 34 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) … … 53 40 54 41 //------------------------------------------------------------------------------ 42 //Initialization 43 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 //------------------------------------------------------------------------------ 55 50 //Capacity 56 51 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 57 static inline bool empty(vector(T, allocator_t) *this)52 static inline bool empty(vector(T, allocator_t) *const this) 58 53 { 59 54 return this->size == 0; … … 61 56 62 57 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 63 static inline size_t size(vector(T, allocator_t) *this)58 static inline size_t size(vector(T, allocator_t) *const this) 64 59 { 65 60 return this->size; … … 67 62 68 63 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 69 static inline void reserve(vector(T, allocator_t) *this, size_t size)64 static inline void reserve(vector(T, allocator_t) *const this, size_t size) 70 65 { 71 66 realloc_storage(&this->storage, this->size+1); … … 75 70 //Element access 76 71 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 77 static inline T at(vector(T, allocator_t) *this, size_t index)72 static inline T at(vector(T, allocator_t) *const this, size_t index) 78 73 { 79 74 return data(&this->storage)[index]; … … 81 76 82 77 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 83 static inline T ?[?](vector(T, allocator_t) *this, size_t index)78 static inline T ?[?](vector(T, allocator_t) *const this, size_t index) 84 79 { 85 80 return data(&this->storage)[index]; … … 87 82 88 83 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 89 static inline T front(vector(T, allocator_t) *this)84 static inline T front(vector(T, allocator_t) *const this) 90 85 { 91 86 return data(&this->storage)[0]; … … 93 88 94 89 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 95 static inline T back(vector(T, allocator_t) *this)90 static inline T back(vector(T, allocator_t) *const this) 96 91 { 97 92 return data(&this->storage)[this->size - 1]; … … 101 96 //Modifiers 102 97 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 103 void push_back(vector(T, allocator_t) *this, T value);98 void push_back(vector(T, allocator_t) *const this, T value); 104 99 105 100 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 106 void pop_back(vector(T, allocator_t) *this);101 void pop_back(vector(T, allocator_t) *const this); 107 102 108 103 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 109 void clear(vector(T, allocator_t) *this);104 void clear(vector(T, allocator_t) *const this); 110 105 111 106 //------------------------------------------------------------------------------ 112 107 //Iterators 113 108 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 114 static inline T* begin(vector(T, allocator_t) *this)109 static inline T* begin(vector(T, allocator_t) *const this) 115 110 { 116 111 return data(&this->storage); … … 118 113 119 114 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 120 static inline const T* cbegin(const vector(T, allocator_t) *this)115 static inline const T* cbegin(const vector(T, allocator_t) *const this) 121 116 { 122 117 return data(&this->storage); … … 124 119 125 120 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 126 static inline T* end(vector(T, allocator_t) *this)121 static inline T* end(vector(T, allocator_t) *const this) 127 122 { 128 123 return data(&this->storage) + this->size; … … 130 125 131 126 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 132 static inline const T* cend(const vector(T, allocator_t) *this)127 static inline const T* cend(const vector(T, allocator_t) *const this) 133 128 { 134 129 return data(&this->storage) + this->size; … … 145 140 146 141 forall(otype T) 147 void ?{}(heap_allocator(T)*this);142 void ctor(heap_allocator(T) *const this); 148 143 149 144 forall(otype T) 150 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);145 void dtor(heap_allocator(T) *const this); 151 146 152 147 forall(otype T) 153 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);148 void realloc_storage(heap_allocator(T) *const this, size_t size); 154 149 155 150 forall(otype T) 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) 151 static inline T* data(heap_allocator(T) *const this) 163 152 { 164 153 return this->storage;
Note:
See TracChangeset
for help on using the changeset viewer.