00001 // 00002 // cartiter_i.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 #ifdef __GNUC__ 00029 #pragma interface 00030 #endif 00031 00032 #ifdef INLINE_FUNCTIONS 00033 #define INLINE inline 00034 #else 00035 #define INLINE 00036 #endif 00037 00038 // ///////////////////////////////////////////////////////////////////////// 00039 00040 INLINE int 00041 CartesianIter::n() 00042 { 00043 return ((l_>=0)?((((l_)+2)*((l_)+1))>>1):0); 00044 } 00045 00046 INLINE int 00047 CartesianIter::a() 00048 { 00049 return a_; 00050 } 00051 00052 INLINE int 00053 CartesianIter::b() 00054 { 00055 return b_; 00056 } 00057 00058 INLINE int 00059 CartesianIter::c() 00060 { 00061 return c_; 00062 } 00063 00064 INLINE int 00065 CartesianIter::l() 00066 { 00067 return l_; 00068 } 00069 00070 INLINE int 00071 CartesianIter::l(int i) 00072 { 00073 return i ? (i==1 ? b_ : c_) : a_; 00074 } 00075 00076 INLINE int 00077 CartesianIter::bfn() 00078 { 00079 return bfn_; 00080 } 00081 00082 // ///////////////////////////////////////////////////////////////////////// 00083 00084 INLINE void 00085 RedundantCartesianIter::start() 00086 { 00087 if (l_==0) 00088 done_ = 1; 00089 else 00090 done_ = 0; 00091 00092 for (int i=0; i<l_; i++) 00093 axis_[i] = 0; 00094 } 00095 00096 INLINE void 00097 RedundantCartesianIter::next() 00098 { 00099 for (int i=0; i<l_; i++) { 00100 if (axis_[i] == 2) 00101 axis_[i] = 0; 00102 else { 00103 axis_[i]++; 00104 return; 00105 } 00106 } 00107 done_ = 1; 00108 } 00109 00110 INLINE 00111 RedundantCartesianIter::operator int() 00112 { 00113 return !done_; 00114 } 00115 00116 INLINE int 00117 RedundantCartesianIter::l() 00118 { 00119 return l_; 00120 } 00121 00122 INLINE int 00123 RedundantCartesianIter::a() 00124 { 00125 return l(0); 00126 } 00127 00128 INLINE int 00129 RedundantCartesianIter::b() 00130 { 00131 return l(1); 00132 } 00133 00134 INLINE int 00135 RedundantCartesianIter::c() 00136 { 00137 return l(2); 00138 } 00139 00140 INLINE int 00141 RedundantCartesianIter::l(int axis) 00142 { 00143 int i; 00144 int r = 0; 00145 for (i=0; i<l_; i++) if (axis_[i]==axis) r++; 00146 return r; 00147 } 00148 00149 INLINE int 00150 RedundantCartesianIter::axis(int i) 00151 { 00152 return axis_[i]; 00153 } 00154 00155 // ///////////////////////////////////////////////////////////////////////// 00156 00157 INLINE 00158 RedundantCartesianSubIter::operator int() 00159 { 00160 return !done_; 00161 } 00162 00163 INLINE 00164 int 00165 RedundantCartesianSubIter::l() 00166 { 00167 return l_; 00168 } 00169 00170 INLINE 00171 int 00172 RedundantCartesianSubIter::a() 00173 { 00174 return e_[0]; 00175 } 00176 00177 INLINE 00178 int 00179 RedundantCartesianSubIter::b() 00180 { 00181 return e_[1]; 00182 } 00183 00184 INLINE 00185 int 00186 RedundantCartesianSubIter::c() 00187 { 00188 return e_[2]; 00189 } 00190 00191 INLINE 00192 int 00193 RedundantCartesianSubIter::l(int i) 00194 { 00195 return e_[i]; 00196 } 00197 00198 INLINE 00199 int 00200 RedundantCartesianSubIter::axis(int i) 00201 { 00202 return axis_[i]; 00203 } 00204 00205 // /////////////////////////////////////////////////////////////////////////// 00206 00207 // Local Variables: 00208 // mode: c++ 00209 // c-file-style: "ETS" 00210 // End: