Ignore:
File:
1 edited

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//
    415
    516#include "iterator.h"
     
    1122///   iterator_type i;
    1223///   for ( i = begin; i != end; ++i ) {
    13 ///    func( *i );
     24///      func( *i );
    1425///   }
    1526/// }
    1627
    1728forall( 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 ) )
    2031void 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        }
    2536}
    2637
    2738forall( 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 ) )
    3041void 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 );
     42        iterator_type i; // "= end;" does not work
     43        i = end;
     44        do {
     45                --i;
     46                os << *i << ' ';
     47        } while ( i != begin );
    3748}
     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.