source: src/examples/vector_int.h @ eab39cd

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since eab39cd was eab39cd, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

update vector_test to use constructors and destructors

  • Property mode set to 100644
File size: 1.4 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// vector_int.h --
8//
9// Author           : Richard C. Bilson
10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Rob Schluntz
12// Last Modified On : Wed Apr 06 17:21:59 2016
13// Update Count     : 2
14//
15
16#ifndef VECTOR_INT_H
17#define VECTOR_INT_H
18
19// A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
20
21typedef struct vector_int {
22        int last;                                                                                       // last used index
23        int capacity;                                                                           // last possible index before reallocation
24        int *data;                                                                                      // array
25} vector_int;
26
27void ?{}( vector_int * );                                                               // allocate vector with default capacity
28void ?{}( vector_int *, int reserve );                                  // allocate vector with specified capacity
29void ^?{}( vector_int * );                                                              // deallocate vector's storage
30
31void reserve( vector_int *vec, int reserve );                   // reserve more capacity
32void append( vector_int *vec, int element );                    // add element to end of vector, resizing as necessary
33
34// implement bounded_array
35
36lvalue int ?[?]( vector_int vec, int index );                   // access to arbitrary element (does not resize)
37int last( vector_int vec );                                                             // return last element
38
39#endif // VECTOR_INT_H
40
41// Local Variables: //
42// tab-width: 4 //
43// compile-command: "cfa vector_int.c" //
44// End: //
Note: See TracBrowser for help on using the repository browser.