source: translator/examples/vector_int.h @ 02e9ae2

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 02e9ae2 was 134b86a, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

add compiler flag to driver, update examples, fix unnamed bit fields

  • Property mode set to 100644
File size: 935 bytes
Line 
1#ifndef VECTOR_INT_H
2#define VECTOR_INT_H
3
4// A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
5
6typedef struct vector_int {
7    int last;                                           // last used index
8    int capacity;                                       // last possible index before reallocation
9    int *data;                                          // array
10} vector_int;
11
12vector_int vector_int_allocate();                       // allocate vector with default capacity
13vector_int vector_int_allocate( int reserve );          // allocate vector with specified capacity
14void vector_int_deallocate( vector_int );               // deallocate vector's storage
15
16void reserve( vector_int *vec, int reserve );           // reserve more capacity
17void append( vector_int *vec, int element );            // add element to end of vector, resizing as necessary
18
19// implement bounded_array
20
21lvalue int ?[?]( vector_int vec, int index );           // access to arbitrary element (does not resize)
22int last( vector_int vec );                             // return last element
23
24#endif // VECTOR_INT_H
Note: See TracBrowser for help on using the repository browser.