source: src/tests/vector/vector_int.h @ 6b0b624

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 6b0b624 was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change #ifndef to #pragma once

  • 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 : Peter A. Buhr
12// Last Modified On : Sat Jul 22 10:04:02 2017
13// Update Count     : 4
14//
15
16#pragma once
17
18// A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
19
20typedef struct vector_int {
21        int last;                                                                                       // last used index
22        int capacity;                                                                           // last possible index before reallocation
23        int *data;                                                                                      // array
24} vector_int;
25
26void ?{}( vector_int * );                                                               // allocate vector with default capacity
27void ?{}( vector_int *, int reserve );                                  // allocate vector with specified capacity
28void ?{}( vector_int * vec, vector_int other );                 // copy constructor
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// Local Variables: //
40// tab-width: 4 //
41// compile-command: "cfa vector_int.c" //
42// End: //
Note: See TracBrowser for help on using the repository browser.