source: src/tests/vector/vector_int.h @ 7bc4e6b

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 7bc4e6b was 9236060, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Merge branch 'master' into references

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[86bd7c1f]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//
[eab39cd]7// vector_int.h --
[86bd7c1f]8//
9// Author           : Richard C. Bilson
10// Created On       : Wed May 27 17:56:53 2015
[6b0b624]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat Jul 22 10:04:02 2017
13// Update Count     : 4
[86bd7c1f]14//
15
[6b0b624]16#pragma once
[51b7345]17
[134b86a]18// A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
[51b7345]19
[134b86a]20typedef struct vector_int {
[86bd7c1f]21        int last;                                                                                       // last used index
22        int capacity;                                                                           // last possible index before reallocation
23        int *data;                                                                                      // array
[134b86a]24} vector_int;
[51b7345]25
[2afec66]26void ?{}( vector_int & );                                                               // allocate vector with default capacity
[9a4e996]27void ?{}( vector_int &, int reserve );                                  // allocate vector with specified capacity
[9236060]28void ?{}( vector_int & vec, vector_int other );     // copy constructor
29void ^?{}( vector_int & );                // deallocate vector's storage
[51b7345]30
[86bd7c1f]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
[51b7345]33
34// implement bounded_array
35
[9a4e996]36int & ?[?]( vector_int * vec, int index );                              // access to arbitrary element (does not resize)
[9236060]37int last( vector_int * vec );             // return last element
[86bd7c1f]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.