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 53a2e97 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
|
Rev | Line | |
---|
[51b73452] | 1 | #ifndef VECTOR_INT_H
|
---|
| 2 | #define VECTOR_INT_H
|
---|
| 3 |
|
---|
[134b86a] | 4 | // A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
|
---|
[51b73452] | 5 |
|
---|
[134b86a] | 6 | typedef struct vector_int {
|
---|
| 7 | int last; // last used index
|
---|
| 8 | int capacity; // last possible index before reallocation
|
---|
| 9 | int *data; // array
|
---|
| 10 | } vector_int;
|
---|
[51b73452] | 11 |
|
---|
[134b86a] | 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
|
---|
[51b73452] | 15 |
|
---|
[134b86a] | 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
|
---|
[51b73452] | 18 |
|
---|
| 19 | // implement bounded_array
|
---|
| 20 |
|
---|
[134b86a] | 21 | lvalue int ?[?]( vector_int vec, int index ); // access to arbitrary element (does not resize)
|
---|
| 22 | int last( vector_int vec ); // return last element
|
---|
[51b73452] | 23 |
|
---|
[134b86a] | 24 | #endif // VECTOR_INT_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.