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
        with_gc
      
      
        
          | 
            Last change
 on this file since 8bc4ef8 was             4040425, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago           | 
        
        
          | 
             
change keyword type to otype and context to trait 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            1.6 KB
           | 
        
      
      
| Line |   | 
|---|
| 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 | // array.h -- 
 | 
|---|
| 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 Mar  2 18:13:35 2016
 | 
|---|
| 13 | // Update Count     : 5
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #ifndef ARRAY_H
 | 
|---|
| 17 | #define ARRAY_H
 | 
|---|
| 18 | 
 | 
|---|
| 19 | //#include <iterator>
 | 
|---|
| 20 | 
 | 
|---|
| 21 | // An array has contiguous elements accessible in any order using integer indicies. The first
 | 
|---|
| 22 | // element has index 0.
 | 
|---|
| 23 | trait array( otype array_type, otype elt_type ) {
 | 
|---|
| 24 |         lvalue elt_type ?[?]( array_type, int );
 | 
|---|
| 25 | };
 | 
|---|
| 26 | 
 | 
|---|
| 27 | // A bounded array is an array that carries its maximum index with it.
 | 
|---|
| 28 | trait bounded_array( otype array_type, otype elt_type | array( array_type, elt_type ) ) {
 | 
|---|
| 29 |         int last( array_type );
 | 
|---|
| 30 | };
 | 
|---|
| 31 | 
 | 
|---|
| 32 | // implement iterator_for
 | 
|---|
| 33 | 
 | 
|---|
| 34 | typedef int array_iterator;
 | 
|---|
| 35 | 
 | 
|---|
| 36 | /// forall( otype array_type, elt_type | bounded_array( array_type, elt_type ) )
 | 
|---|
| 37 | /// [ array_iterator begin, array_iterator end ] get_iterators( array_type );
 | 
|---|
| 38 | 
 | 
|---|
| 39 | 
 | 
|---|
| 40 | // A bounded array can be iterated over by using a pointer to the element type. These functions
 | 
|---|
| 41 | // return iterators corresponding to the first element and the one-past-the-end element, STL-style.
 | 
|---|
| 42 | forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
 | 
|---|
| 43 | elt_type *begin( array_type );
 | 
|---|
| 44 | 
 | 
|---|
| 45 | forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
 | 
|---|
| 46 | elt_type *end( array_type );
 | 
|---|
| 47 | 
 | 
|---|
| 48 | #endif // ARRAY_H
 | 
|---|
| 49 | 
 | 
|---|
| 50 | // Local Variables: //
 | 
|---|
| 51 | // tab-width: 4 //
 | 
|---|
| 52 | // compile-command: "cfa array.c" //
 | 
|---|
| 53 | // End: //
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.