Changeset 134b86a for translator/examples/vector_int.h
- Timestamp:
- Nov 3, 2014, 4:38:08 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 8c17ab0
- Parents:
- 93885663
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/examples/vector_int.h
r93885663 r134b86a 2 2 #define VECTOR_INT_H 3 3 4 typedef struct vector_int 5 { 6 int last; 7 int capacity; 8 int *data; 4 // A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically 5 6 typedef struct vector_int { 7 int last; // last used index 8 int capacity; // last possible index before reallocation 9 int *data; // array 9 10 } vector_int; 10 11 12 vector_int vector_int_allocate(); // allocate vector with default capacity 13 vector_int vector_int_allocate( int reserve ); // allocate vector with specified capacity 14 void vector_int_deallocate( vector_int ); // deallocate vector's storage 11 15 12 vector_int vector_int_allocate(); 13 vector_int vector_int_allocate( int reserve ); 14 void vector_int_deallocate( vector_int ); 15 16 void reserve( vector_int *vec, int reserve ); 17 void append( vector_int *vec, int element ); 16 void reserve( vector_int *vec, int reserve ); // reserve more capacity 17 void append( vector_int *vec, int element ); // add element to end of vector, resizing as necessary 18 18 19 19 // implement bounded_array 20 20 21 lvalue int ?[?]( vector_int vec, int index ); 22 int array_last( vector_int vec );21 lvalue int ?[?]( vector_int vec, int index ); // access to arbitrary element (does not resize) 22 int last( vector_int vec ); // return last element 23 23 24 #endif / * #ifndef VECTOR_INT_H */24 #endif // VECTOR_INT_H
Note: See TracChangeset
for help on using the changeset viewer.