Ignore:
Timestamp:
May 17, 2015, 1:19:35 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
0dd3a2f
Parents:
b87a5ed
Message:

licencing: second groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/ResolvExpr/Cost.h

    rb87a5ed ra32b204  
    1 #ifndef RESOLVEXPR_COST_H
    2 #define RESOLVEXPR_COST_H
     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// Cost.h --
     8//
     9// Author           : Richard C. Bilson
     10// Created On       : Sun May 17 09:39:50 2015
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun May 17 09:42:04 2015
     13// Update Count     : 3
     14//
     15
     16#ifndef COST_H
     17#define COST_H
    318
    419#include <iostream>
    520
    621namespace ResolvExpr {
    7     class Cost {
    8       public:
    9         Cost();
    10         Cost( int unsafe, int poly, int safe );
     22        class Cost {
     23          public:
     24                Cost();
     25                Cost( int unsafe, int poly, int safe );
    1126 
    12         void incUnsafe( int inc = 1 );
    13         void incPoly( int inc = 1 );
    14         void incSafe( int inc = 1 );
     27                void incUnsafe( int inc = 1 );
     28                void incPoly( int inc = 1 );
     29                void incSafe( int inc = 1 );
    1530 
    16         Cost operator+( const Cost &other ) const;
    17         Cost operator-( const Cost &other ) const;
    18         Cost &operator+=( const Cost &other );
    19         bool operator<( const Cost &other ) const;
    20         bool operator==( const Cost &other ) const;
    21         bool operator!=( const Cost &other ) const;
    22         friend std::ostream &operator<<( std::ostream &os, const Cost &cost );
     31                Cost operator+( const Cost &other ) const;
     32                Cost operator-( const Cost &other ) const;
     33                Cost &operator+=( const Cost &other );
     34                bool operator<( const Cost &other ) const;
     35                bool operator==( const Cost &other ) const;
     36                bool operator!=( const Cost &other ) const;
     37                friend std::ostream &operator<<( std::ostream &os, const Cost &cost );
    2338 
    24         static const Cost zero;
    25         static const Cost infinity;
    26       private:
    27         int compare( const Cost &other ) const;
     39                static const Cost zero;
     40                static const Cost infinity;
     41          private:
     42                int compare( const Cost &other ) const;
    2843
    29         int unsafe;
    30         int poly;
    31         int safe;
    32     };
     44                int unsafe;
     45                int poly;
     46                int safe;
     47        };
    3348
    34     inline Cost::Cost() : unsafe( 0 ), poly( 0 ), safe( 0 ) {}
     49        inline Cost::Cost() : unsafe( 0 ), poly( 0 ), safe( 0 ) {}
    3550
    36     inline Cost::Cost( int unsafe, int poly, int safe ) : unsafe( unsafe ), poly( poly ), safe( safe ) {}
     51        inline Cost::Cost( int unsafe, int poly, int safe ) : unsafe( unsafe ), poly( poly ), safe( safe ) {}
    3752
    38     inline void
    39         Cost::incUnsafe( int inc ) {
    40         unsafe += inc;
    41     }
     53        inline void Cost::incUnsafe( int inc ) {
     54                unsafe += inc;
     55        }
    4256
    43     inline void
    44         Cost::incPoly( int inc ) {
    45         unsafe += inc;
    46     }
     57        inline void Cost::incPoly( int inc ) {
     58                unsafe += inc;
     59        }
    4760
    48     inline void
    49         Cost::incSafe( int inc ) {
    50         unsafe += inc;
    51     }
     61        inline void Cost::incSafe( int inc ) {
     62                unsafe += inc;
     63        }
    5264
    53     inline Cost Cost::operator+( const Cost &other ) const {
    54         return Cost( unsafe + other.unsafe, poly + other.poly, safe + other.safe );
    55     }
     65        inline Cost Cost::operator+( const Cost &other ) const {
     66                return Cost( unsafe + other.unsafe, poly + other.poly, safe + other.safe );
     67        }
    5668
    57     inline Cost Cost::operator-( const Cost &other ) const {
    58         return Cost( unsafe - other.unsafe, poly - other.poly, safe - other.safe );
    59     }
     69        inline Cost Cost::operator-( const Cost &other ) const {
     70                return Cost( unsafe - other.unsafe, poly - other.poly, safe - other.safe );
     71        }
    6072
    61     inline Cost &Cost::operator+=( const Cost &other ) {
    62         unsafe += other.unsafe;
    63         poly += other.poly;
    64         safe += other.safe;
    65         return *this;
    66     }
     73        inline Cost &Cost::operator+=( const Cost &other ) {
     74                unsafe += other.unsafe;
     75                poly += other.poly;
     76                safe += other.safe;
     77                return *this;
     78        }
    6779
    68     inline bool Cost::operator<( const Cost &other ) const {
     80        inline bool Cost::operator<( const Cost &other ) const {
    6981            if ( *this == infinity ) return false;
    7082            if ( other == infinity ) return true;
    7183            if ( unsafe > other.unsafe ) {
    72                 return false;
     84                        return false;
    7385            } else if ( unsafe < other.unsafe ) {
    74                 return true;
     86                        return true;
    7587            } else if ( poly > other.poly ) {
    76                 return false;
     88                        return false;
    7789            } else if ( poly < other.poly ) {
    78                 return true;
     90                        return true;
    7991            } else if ( safe > other.safe ) {
    80                 return false;
     92                        return false;
    8193            } else if ( safe < other.safe ) {
    82                 return true;
     94                        return true;
    8395            } else {
    84                 return false;
    85             }
     96                        return false;
     97            } // if
    8698        }
    8799
    88     inline bool Cost::operator==( const Cost &other ) const {
    89         return unsafe == other.unsafe
    90         && poly == other.poly
    91         && safe == other.safe;
    92     }
     100        inline bool Cost::operator==( const Cost &other ) const {
     101                return unsafe == other.unsafe
     102                        && poly == other.poly
     103                        && safe == other.safe;
     104        }
    93105
    94     inline bool Cost::operator!=( const Cost &other ) const {
    95         return !( *this == other );
    96     }
     106        inline bool Cost::operator!=( const Cost &other ) const {
     107                return !( *this == other );
     108        }
    97109
    98     inline std::ostream &operator<<( std::ostream &os, const Cost &cost ) {
    99         os << "( " << cost.unsafe << ", " << cost.poly << ", " << cost.safe << " )";
    100         return os;
    101     }
     110        inline std::ostream &operator<<( std::ostream &os, const Cost &cost ) {
     111                os << "( " << cost.unsafe << ", " << cost.poly << ", " << cost.safe << " )";
     112                return os;
     113        }
    102114} // namespace ResolvExpr
    103115
    104 #endif // RESOLVEXPR_COST_H
     116#endif // COST_H
     117
     118// Local Variables: //
     119// tab-width: 4 //
     120// mode: c++ //
     121// compile-command: "make install" //
     122// End: //
Note: See TracChangeset for help on using the changeset viewer.