Changeset 76934fb for src/examples/iterator.c
- Timestamp:
- Jun 1, 2015, 12:55:33 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 6db50d5
- Parents:
- 46cbfe1 (diff), db82596 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/iterator.c
r46cbfe1 r76934fb 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 /// 24 /// func( *i ); 14 25 /// } 15 26 /// } 16 27 17 28 forall( type elt_type | writeable( elt_type ), 18 19 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 22 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 32 33 34 --i;35 os << *i << ' ';36 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.