ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        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 a0c7dc36 was             9236060, checked in by Rob Schluntz <rschlunt@…>, 8 years ago | 
        
          | 
Merge branch 'master' into references
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.6 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 | // | 
|---|
| [1ad1c99e] | 7 | // array.h -- | 
|---|
| [86bd7c1f] | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Wed May 27 17:56:53 2015 | 
|---|
| [6b0b624] | 11 | // Last Modified By : Peter A. Buhr | 
|---|
|  | 12 | // Last Modified On : Sat Jul 22 10:04:20 2017 | 
|---|
|  | 13 | // Update Count     : 6 | 
|---|
| [86bd7c1f] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [6b0b624] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [d3b7937] | 18 | //#include <iterator> | 
|---|
| [51b73452] | 19 |  | 
|---|
| [134b86a] | 20 | // An array has contiguous elements accessible in any order using integer indicies. The first | 
|---|
|  | 21 | // element has index 0. | 
|---|
| [4040425] | 22 | trait array( otype array_type, otype elt_type ) { | 
|---|
| [9a4e996] | 23 | elt_type & ?[?]( array_type, int ); | 
|---|
| [51b73452] | 24 | }; | 
|---|
|  | 25 |  | 
|---|
| [134b86a] | 26 | // A bounded array is an array that carries its maximum index with it. | 
|---|
| [1ad1c99e] | 27 | trait bounded_array( otype array_type, otype elt_type | array( array_type *, elt_type ) ) { | 
|---|
|  | 28 | int last( array_type * ); | 
|---|
| [51b73452] | 29 | }; | 
|---|
|  | 30 |  | 
|---|
|  | 31 | // implement iterator_for | 
|---|
|  | 32 |  | 
|---|
| [4a9ccc3] | 33 | forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) | 
|---|
|  | 34 | [ elt_type * begin, elt_type * end ] get_iterators( array_type * ); | 
|---|
| [134b86a] | 35 |  | 
|---|
|  | 36 |  | 
|---|
|  | 37 | // A bounded array can be iterated over by using a pointer to the element type. These functions | 
|---|
|  | 38 | // return iterators corresponding to the first element and the one-past-the-end element, STL-style. | 
|---|
| [4040425] | 39 | forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) | 
|---|
| [1ad1c99e] | 40 | elt_type * begin( array_type * array ); | 
|---|
| [134b86a] | 41 |  | 
|---|
| [1ad1c99e] | 42 | // The end iterator should point one past the last element. | 
|---|
| [4040425] | 43 | forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) | 
|---|
| [1ad1c99e] | 44 | elt_type * end( array_type * array ); | 
|---|
| [51b73452] | 45 |  | 
|---|
| [86bd7c1f] | 46 | // Local Variables: // | 
|---|
|  | 47 | // tab-width: 4 // | 
|---|
|  | 48 | // compile-command: "cfa array.c" // | 
|---|
|  | 49 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.