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