ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change
on this file since ce28c7b was
4bf3b2b,
checked in by Peter A. Buhr <pabuhr@…>, 7 years ago
|
additional cleanup for vector
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[bd34fc87] | 1 | // |
---|
[00b7cd3] | 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
[bd34fc87] | 6 | // |
---|
[4bf3b2b] | 7 | // vector.c -- |
---|
[bd34fc87] | 8 | // |
---|
[00b7cd3] | 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Mon Jul 4 23:36:19 2016 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[4bf3b2b] | 12 | // Last Modified On : Thu Jan 18 17:08:08 2018 |
---|
| 13 | // Update Count : 27 |
---|
[bd34fc87] | 14 | // |
---|
[ea29e73] | 15 | |
---|
[00b7cd3] | 16 | #include <fstream> |
---|
| 17 | #include <vector> |
---|
| 18 | |
---|
| 19 | #undef assert |
---|
| 20 | #define assert(x) \ |
---|
| 21 | do { \ |
---|
| 22 | if ( !(x) ) { \ |
---|
| 23 | sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__ | endl; \ |
---|
| 24 | abort(); \ |
---|
| 25 | } \ |
---|
| 26 | } while( 0 == 1 ) |
---|
| 27 | |
---|
| 28 | int main() { |
---|
[67cf18c] | 29 | vector( int ) iv; |
---|
[00b7cd3] | 30 | |
---|
| 31 | assert( empty( &iv ) ); |
---|
| 32 | assert( size( &iv ) == 0 ); |
---|
| 33 | sout | size( &iv ) | endl; |
---|
| 34 | |
---|
| 35 | push_back( &iv, 1 ); |
---|
| 36 | assert( size( &iv ) == 1 ); |
---|
| 37 | sout | size( &iv ) | endl; |
---|
[ed3f3bf4] | 38 | |
---|
[00b7cd3] | 39 | push_back( &iv, 2 ); |
---|
| 40 | assert( size( &iv ) == 2 ); |
---|
| 41 | sout | size( &iv ) | endl; |
---|
| 42 | |
---|
| 43 | push_back( &iv, 3 ); |
---|
| 44 | assert( size( &iv ) == 3 ); |
---|
| 45 | sout | size( &iv ) | endl; |
---|
| 46 | |
---|
| 47 | assert( !empty( &iv ) ); |
---|
| 48 | assert( size( &iv ) == 3 ); |
---|
| 49 | assert( at( &iv, 0 ) == 1 ); |
---|
| 50 | assert( (&iv)[0] == 1 ); |
---|
| 51 | assert( at( &iv, 1 ) == 2 ); |
---|
| 52 | assert( (&iv)[1] == 2 ); |
---|
| 53 | assert( at( &iv, 2 ) == 3 ); |
---|
| 54 | assert( (&iv)[2] == 3 ); |
---|
| 55 | |
---|
| 56 | clear( &iv ); |
---|
| 57 | |
---|
| 58 | assert( empty( &iv ) ); |
---|
| 59 | assert( size( &iv ) == 0 ); |
---|
| 60 | sout | size( &iv ) | endl; |
---|
[ea29e73] | 61 | } |
---|
[00b7cd3] | 62 | |
---|
| 63 | // Local Variables: // |
---|
| 64 | // tab-width: 4 // |
---|
[4bf3b2b] | 65 | // compile-command: "cfa vector.c" // |
---|
[00b7cd3] | 66 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.