Ignore:
File:
1 edited

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"
    154
    165#include "iterator.h"
     
    2211///   iterator_type i;
    2312///   for ( i = begin; i != end; ++i ) {
    24 ///      func( *i );
     13///    func( *i );
    2514///   }
    2615/// }
    2716
    2817forall( 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 ) )
    3120void 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    }
    3625}
    3726
    3827forall( 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 ) )
    4130void write_reverse( iterator_type begin, iterator_type end, os_type *os ) {
    42         iterator_type i; // "= end;" does not work
    43         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 );
    4837}
    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.