Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/vector

    rbd34fc87 r60aa49a7  
    2020}
    2121
     22#define DESTROY(x)
     23
    2224//------------------------------------------------------------------------------
    2325//Declaration
    2426trait allocator_c(otype T, otype allocator_t)
    2527{
    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);
    2832};
    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);
    4633
    4734forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     
    5340
    5441//------------------------------------------------------------------------------
     42//Initialization
     43forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     44void ctor(vector(T, allocator_t) *const this);
     45
     46forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     47void dtor(vector(T, allocator_t) *const this);
     48
     49//------------------------------------------------------------------------------
    5550//Capacity
    5651forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    57 static inline bool empty(vector(T, allocator_t)* this)
     52static inline bool empty(vector(T, allocator_t) *const this)
    5853{
    5954        return this->size == 0;
     
    6156
    6257forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    63 static inline size_t size(vector(T, allocator_t)* this)
     58static inline size_t size(vector(T, allocator_t) *const this)
    6459{
    6560        return this->size;
     
    6762
    6863forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    69 static inline void reserve(vector(T, allocator_t)* this, size_t size)
     64static inline void reserve(vector(T, allocator_t) *const this, size_t size)
    7065{
    7166        realloc_storage(&this->storage, this->size+1);
     
    7570//Element access
    7671forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    77 static inline T at(vector(T, allocator_t)* this, size_t index)
     72static inline T at(vector(T, allocator_t) *const this, size_t index)
    7873{
    7974        return data(&this->storage)[index];
     
    8176
    8277forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    83 static inline T ?[?](vector(T, allocator_t)* this, size_t index)
     78static inline T ?[?](vector(T, allocator_t) *const this, size_t index)
    8479{
    8580        return data(&this->storage)[index];
     
    8782
    8883forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    89 static inline T front(vector(T, allocator_t)* this)
     84static inline T front(vector(T, allocator_t) *const this)
    9085{
    9186        return data(&this->storage)[0];
     
    9388
    9489forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    95 static inline T back(vector(T, allocator_t)* this)
     90static inline T back(vector(T, allocator_t) *const this)
    9691{
    9792        return data(&this->storage)[this->size - 1];
     
    10196//Modifiers
    10297forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    103 void push_back(vector(T, allocator_t)* this, T value);
     98void push_back(vector(T, allocator_t) *const this, T value);
    10499
    105100forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    106 void pop_back(vector(T, allocator_t)* this);
     101void pop_back(vector(T, allocator_t) *const this);
    107102
    108103forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    109 void clear(vector(T, allocator_t)* this);
     104void clear(vector(T, allocator_t) *const this);
    110105
    111106//------------------------------------------------------------------------------
    112107//Iterators
    113108forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    114 static inline T* begin(vector(T, allocator_t)* this)
     109static inline T* begin(vector(T, allocator_t) *const this)
    115110{
    116111        return data(&this->storage);
     
    118113
    119114forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    120 static inline const T* cbegin(const vector(T, allocator_t)* this)
     115static inline const T* cbegin(const vector(T, allocator_t) *const this)
    121116{
    122117        return data(&this->storage);
     
    124119
    125120forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    126 static inline T* end(vector(T, allocator_t)* this)
     121static inline T* end(vector(T, allocator_t) *const this)
    127122{
    128123        return data(&this->storage) + this->size;
     
    130125
    131126forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    132 static inline const T* cend(const vector(T, allocator_t)* this)
     127static inline const T* cend(const vector(T, allocator_t) *const this)
    133128{
    134129        return data(&this->storage) + this->size;
     
    145140
    146141forall(otype T)
    147 void ?{}(heap_allocator(T)* this);
     142void ctor(heap_allocator(T) *const this);
    148143
    149144forall(otype T)
    150 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
     145void dtor(heap_allocator(T) *const this);
    151146
    152147forall(otype T)
    153 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
     148void realloc_storage(heap_allocator(T) *const this, size_t size);
    154149
    155150forall(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)
     151static inline T* data(heap_allocator(T) *const this)
    163152{
    164153        return this->storage;
Note: See TracChangeset for help on using the changeset viewer.