ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change
on this file since ecb1534 was
843054c2,
checked in by Peter A. Buhr <pabuhr@…>, 10 years ago
|
licencing: seventh groups of files
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | // "cfa iterator.c" |
---|
2 | // "cfa -CFA iterator.c > iterator_out.c" |
---|
3 | // "gcc31 iterator_out.c ../LibCfa/libcfa.a" |
---|
4 | |
---|
5 | #include "iterator.h" |
---|
6 | |
---|
7 | /// forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) ) |
---|
8 | /// void |
---|
9 | /// for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) |
---|
10 | /// { |
---|
11 | /// iterator_type i; |
---|
12 | /// for ( i = begin; i != end; ++i ) { |
---|
13 | /// func( *i ); |
---|
14 | /// } |
---|
15 | /// } |
---|
16 | |
---|
17 | forall( type elt_type | writeable( elt_type ), |
---|
18 | type iterator_type | iterator( iterator_type, elt_type ), |
---|
19 | dtype os_type | ostream( os_type ) ) |
---|
20 | 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 | } |
---|
25 | } |
---|
26 | |
---|
27 | forall( type elt_type | writeable( elt_type ), |
---|
28 | type iterator_type | iterator( iterator_type, elt_type ), |
---|
29 | dtype os_type | ostream( os_type ) ) |
---|
30 | void write_reverse( iterator_type begin, iterator_type end, os_type *os ) { |
---|
31 | iterator_type i; // "= end;" does not work |
---|
32 | i = end; |
---|
33 | do { |
---|
34 | --i; |
---|
35 | os << *i << ' '; |
---|
36 | } while ( i != begin ); |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.