ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        ctor
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        gc_noraii
        jacob/cs343-translation
        jenkins-sandbox
        memory
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        string
        with_gc
      
      
        
          | Last change
 on this file since 724c2b6 was             86bd7c1f, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago | 
        
          | 
licencing: eighth groups of files
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.4 KB | 
      
      
| Rev | Line |  | 
|---|
| [86bd7c1f] | 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 | // | 
|---|
| [51b73452] | 15 |  | 
|---|
|  | 16 | #include "iterator.h" | 
|---|
|  | 17 |  | 
|---|
|  | 18 | /// forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) ) | 
|---|
|  | 19 | /// void | 
|---|
|  | 20 | /// for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) | 
|---|
|  | 21 | /// { | 
|---|
|  | 22 | ///   iterator_type i; | 
|---|
| [a32b204] | 23 | ///   for ( i = begin; i != end; ++i ) { | 
|---|
| [86bd7c1f] | 24 | ///      func( *i ); | 
|---|
| [51b73452] | 25 | ///   } | 
|---|
|  | 26 | /// } | 
|---|
|  | 27 |  | 
|---|
|  | 28 | forall( type elt_type | writeable( elt_type ), | 
|---|
| [86bd7c1f] | 29 | type iterator_type | iterator( iterator_type, elt_type ), | 
|---|
|  | 30 | dtype os_type | ostream( os_type ) ) | 
|---|
| [134b86a] | 31 | void write_all( iterator_type begin, iterator_type end, os_type *os ) { | 
|---|
| [86bd7c1f] | 32 | iterator_type i; | 
|---|
|  | 33 | for ( i = begin; i != end; ++i ) { | 
|---|
|  | 34 | os << *i << ' '; | 
|---|
|  | 35 | } | 
|---|
| [51b73452] | 36 | } | 
|---|
|  | 37 |  | 
|---|
| [134b86a] | 38 | forall( type elt_type | writeable( elt_type ), | 
|---|
| [86bd7c1f] | 39 | type iterator_type | iterator( iterator_type, elt_type ), | 
|---|
|  | 40 | dtype os_type | ostream( os_type ) ) | 
|---|
| [134b86a] | 41 | void write_reverse( iterator_type begin, iterator_type end, os_type *os ) { | 
|---|
| [86bd7c1f] | 42 | iterator_type i; // "= end;" does not work | 
|---|
|  | 43 | i = end; | 
|---|
|  | 44 | do { | 
|---|
|  | 45 | --i; | 
|---|
|  | 46 | os << *i << ' '; | 
|---|
|  | 47 | } while ( i != begin ); | 
|---|
| [134b86a] | 48 | } | 
|---|
| [86bd7c1f] | 49 |  | 
|---|
|  | 50 | // Local Variables: // | 
|---|
|  | 51 | // tab-width: 4 // | 
|---|
|  | 52 | // compile-command: "cfa iterator.c" // | 
|---|
|  | 53 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.