source: src/examples/vector_int.h@ 2bae7307

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 2bae7307 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

licencing: seventh groups of files

  • 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.