Ignore:
Timestamp:
Sep 19, 2016, 5:23:45 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/vector

    r89e6ffc ra6fe3de  
    2020}
    2121
    22 #define DESTROY(x)
    23 
    2422//------------------------------------------------------------------------------
    2523//Declaration
    2624trait allocator_c(otype T, otype allocator_t)
    2725{
    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*);
    3228};
     29
     30forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     31struct vector;
     32
     33//------------------------------------------------------------------------------
     34//Initialization
     35forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     36void ?{}(vector(T, allocator_t)* this);
     37
     38forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     39void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs);
     40
     41forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     42vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs);
     43
     44forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     45void ^?{}(vector(T, allocator_t)* this);
    3346
    3447forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     
    4053
    4154//------------------------------------------------------------------------------
    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 //------------------------------------------------------------------------------
    5055//Capacity
    5156forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    52 static inline bool empty(vector(T, allocator_t) *const this)
     57static inline bool empty(vector(T, allocator_t)* this)
    5358{
    5459        return this->size == 0;
     
    5661
    5762forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    58 static inline size_t size(vector(T, allocator_t) *const this)
     63static inline size_t size(vector(T, allocator_t)* this)
    5964{
    6065        return this->size;
     
    6267
    6368forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    64 static inline void reserve(vector(T, allocator_t) *const this, size_t size)
     69static inline void reserve(vector(T, allocator_t)* this, size_t size)
    6570{
    6671        realloc_storage(&this->storage, this->size+1);
     
    7075//Element access
    7176forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    72 static inline T at(vector(T, allocator_t) *const this, size_t index)
     77static inline T at(vector(T, allocator_t)* this, size_t index)
    7378{
    7479        return data(&this->storage)[index];
     
    7681
    7782forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    78 static inline T ?[?](vector(T, allocator_t) *const this, size_t index)
     83static inline T ?[?](vector(T, allocator_t)* this, size_t index)
    7984{
    8085        return data(&this->storage)[index];
     
    8287
    8388forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    84 static inline T front(vector(T, allocator_t) *const this)
     89static inline T front(vector(T, allocator_t)* this)
    8590{
    8691        return data(&this->storage)[0];
     
    8893
    8994forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    90 static inline T back(vector(T, allocator_t) *const this)
     95static inline T back(vector(T, allocator_t)* this)
    9196{
    9297        return data(&this->storage)[this->size - 1];
     
    96101//Modifiers
    97102forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    98 void push_back(vector(T, allocator_t) *const this, T value);
     103void push_back(vector(T, allocator_t)* this, T value);
    99104
    100105forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    101 void pop_back(vector(T, allocator_t) *const this);
     106void pop_back(vector(T, allocator_t)* this);
    102107
    103108forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    104 void clear(vector(T, allocator_t) *const this);
     109void clear(vector(T, allocator_t)* this);
    105110
    106111//------------------------------------------------------------------------------
    107112//Iterators
    108113forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    109 static inline T* begin(vector(T, allocator_t) *const this)
     114static inline T* begin(vector(T, allocator_t)* this)
    110115{
    111116        return data(&this->storage);
     
    113118
    114119forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    115 static inline const T* cbegin(const vector(T, allocator_t) *const this)
     120static inline const T* cbegin(const vector(T, allocator_t)* this)
    116121{
    117122        return data(&this->storage);
     
    119124
    120125forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    121 static inline T* end(vector(T, allocator_t) *const this)
     126static inline T* end(vector(T, allocator_t)* this)
    122127{
    123128        return data(&this->storage) + this->size;
     
    125130
    126131forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    127 static inline const T* cend(const vector(T, allocator_t) *const this)
     132static inline const T* cend(const vector(T, allocator_t)* this)
    128133{
    129134        return data(&this->storage) + this->size;
     
    140145
    141146forall(otype T)
    142 void ctor(heap_allocator(T) *const this);
     147void ?{}(heap_allocator(T)* this);
    143148
    144149forall(otype T)
    145 void dtor(heap_allocator(T) *const this);
     150void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
    146151
    147152forall(otype T)
    148 void realloc_storage(heap_allocator(T) *const this, size_t size);
     153heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
    149154
    150155forall(otype T)
    151 static inline T* data(heap_allocator(T) *const this)
     156void ^?{}(heap_allocator(T)* this);
     157
     158forall(otype T)
     159void realloc_storage(heap_allocator(T)* this, size_t size);
     160
     161forall(otype T)
     162static inline T* data(heap_allocator(T)* this)
    152163{
    153164        return this->storage;
Note: See TracChangeset for help on using the changeset viewer.