Changes in src/examples/iterator.c [843054c2:86bd7c1f]
- File:
-
- 1 edited
-
src/examples/iterator.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/iterator.c
r843054c2 r86bd7c1f 1 // "cfa iterator.c" 2 // "cfa -CFA iterator.c > iterator_out.c" 3 // "gcc31 iterator_out.c ../LibCfa/libcfa.a" 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 // iterator.c -- 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 : Wed May 27 18:41:41 2015 13 // Update Count : 3 14 // 4 15 5 16 #include "iterator.h" … … 11 22 /// iterator_type i; 12 23 /// for ( i = begin; i != end; ++i ) { 13 /// func( *i );24 /// func( *i ); 14 25 /// } 15 26 /// } 16 27 17 28 forall( type elt_type | writeable( elt_type ), 18 type iterator_type | iterator( iterator_type, elt_type ),19 dtype os_type | ostream( os_type ) )29 type iterator_type | iterator( iterator_type, elt_type ), 30 dtype os_type | ostream( os_type ) ) 20 31 void write_all( iterator_type begin, iterator_type end, os_type *os ) { 21 iterator_type i;22 for ( i = begin; i != end; ++i ) {23 os << *i << ' ';24 }32 iterator_type i; 33 for ( i = begin; i != end; ++i ) { 34 os << *i << ' '; 35 } 25 36 } 26 37 27 38 forall( type elt_type | writeable( elt_type ), 28 type iterator_type | iterator( iterator_type, elt_type ),29 dtype os_type | ostream( os_type ) )39 type iterator_type | iterator( iterator_type, elt_type ), 40 dtype os_type | ostream( os_type ) ) 30 41 void write_reverse( iterator_type begin, iterator_type end, os_type *os ) { 31 iterator_type i; // "= end;" does not work32 i = end;33 do {34 --i;35 os << *i << ' ';36 } while ( i != begin );42 iterator_type i; // "= end;" does not work 43 i = end; 44 do { 45 --i; 46 os << *i << ' '; 47 } while ( i != begin ); 37 48 } 49 50 // Local Variables: // 51 // tab-width: 4 // 52 // compile-command: "cfa iterator.c" // 53 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.