|
Sierra Toolkit Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 #ifndef stk_search_IdentProc_hpp 00010 #define stk_search_IdentProc_hpp 00011 00012 #include <ostream> 00013 #include <iomanip> 00014 00015 #include <stk_search/SearchTypes.hpp> 00016 #include <stk_util/util/SimpleArrayOps.hpp> 00017 00018 namespace stk { 00019 namespace search { 00020 namespace ident { 00021 00027 template <class K = uint64_t, class P = unsigned> 00028 struct IdentProc { 00029 00030 typedef K Key; 00031 typedef P Proc; 00032 00037 IdentProc() 00038 : ident(), 00039 proc() 00040 {} 00041 00046 ~IdentProc() 00047 {} 00048 00055 IdentProc( const IdentProc & rhs ) 00056 : ident(rhs.ident), 00057 proc(rhs.proc) 00058 {} 00059 00068 IdentProc( Key i , Proc p ) 00069 : ident(i), 00070 proc(p) 00071 {} 00072 00080 IdentProc & operator = ( const IdentProc & rhs ) { 00081 ident = rhs.ident ; 00082 proc = rhs.proc ; 00083 return *this ; 00084 } 00092 inline bool operator==( const IdentProc<K, P> & rhs ) const { 00093 return !( (ident < rhs.ident || rhs.ident < ident) || 00094 (proc < rhs.proc || rhs.proc < proc ) ); 00095 } 00096 00104 inline bool operator<( const IdentProc<K, P> & rhs ) const { 00105 return ident < rhs.ident || (!(rhs.ident < ident) && proc < rhs.proc); 00106 } 00107 00115 inline bool operator!=( const IdentProc<K, P> &rhs ) const { 00116 return ( (ident < rhs.ident || rhs.ident < ident) || 00117 (proc < rhs.proc || rhs.proc < proc ) ); 00118 } 00119 00127 inline bool operator>( const IdentProc<K, P> &rhs ) const{ 00128 return rhs < *this; 00129 } 00130 00138 inline bool operator<=( const IdentProc<K, P> &rhs ) const { 00139 return !(rhs < *this); 00140 } 00141 00149 inline bool operator>=(const IdentProc<K, P> &rhs ) const { 00150 return !(*this < rhs); 00151 } 00152 00153 00154 Key ident; 00155 Proc proc; 00156 }; 00157 00158 00159 template <class K, class P> 00160 std::ostream& operator<<(std::ostream &dout, const IdentProc<K, P> &ident_proc){ 00161 dout << "id " << ident_proc.ident << ", proc " << ident_proc.proc; 00162 return dout; 00163 } 00164 00165 00166 } // namespace ident 00167 } // namespace search 00168 } // namespace stk 00169 00170 #endif