Ignore:
Timestamp:
Oct 27, 2009, 8:54:44 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
8b6ee4
Parents:
2e6aa1
Message:

Begun with ticket #38 (make const what is const).

  • basically all changes to member function that now state that they do not change member attributes.
  • in molecule_template.hpp all member functions are declared const, as we only need start and end from molecule and these are never changed (lots of overloaded templates removed thereby).
  • Vector::Distance...() and ...DistanceSquared() are const now too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecule_template.hpp

    r2e6aa1 r94d0ad  
    2121
    2222// zero arguments
    23 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() )
    24 {
    25   atom *Walker = start;
    26   while (Walker->next != end) {
    27     Walker = Walker->next;
    28     ((Walker->node)->*f)();
    29   }
    30 };
    31 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const )
    32 {
    33   atom *Walker = start;
    34   while (Walker->next != end) {
    35     Walker = Walker->next;
    36     ((Walker->node)->*f)();
    37   }
    38 };
    3923template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
    4024    {
     
    5438};
    5539// one argument
    56 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t )
     40template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    5741{
    5842  atom *Walker = start;
     
    6246  }
    6347};
    64 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t )
     48template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    6549{
    6650  atom *Walker = start;
     
    7054  }
    7155};
    72 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    73 {
    74   atom *Walker = start;
    75   while (Walker->next != end) {
    76     Walker = Walker->next;
    77     ((Walker->node)->*f)(t);
    78   }
    79 };
    80 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    81 {
    82   atom *Walker = start;
    83   while (Walker->next != end) {
    84     Walker = Walker->next;
    85     ((Walker->node)->*f)(t);
    86   }
    87 };
    8856// two arguments
    89 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u )
     57template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    9058{
    9159  atom *Walker = start;
     
    9563  }
    9664};
    97 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u )
     65template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    9866{
    9967  atom *Walker = start;
     
    10371  }
    10472};
    105 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    106 {
    107   atom *Walker = start;
    108   while (Walker->next != end) {
    109     Walker = Walker->next;
    110     ((Walker->node)->*f)(t, u);
    111   }
    112 };
    113 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    114 {
    115   atom *Walker = start;
    116   while (Walker->next != end) {
    117     Walker = Walker->next;
    118     ((Walker->node)->*f)(t, u);
    119   }
    120 };
    12173// three arguments
    122 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v)
     74template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    12375{
    12476  atom *Walker = start;
     
    12880  }
    12981};
    130 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v)
     82template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
    13183{
    13284  atom *Walker = start;
     
    13688  }
    13789};
    138 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    139 {
    140   atom *Walker = start;
    141   while (Walker->next != end) {
    142     Walker = Walker->next;
    143     ((Walker->node)->*f)(t, u, v);
    144   }
    145 };
    146 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
    147 {
    148   atom *Walker = start;
    149   while (Walker->next != end) {
    150     Walker = Walker->next;
    151     ((Walker->node)->*f)(t, u, v);
    152   }
    153 };
    15490
    15591// ========================= Summing over each Atoms =================================== //
    15692
    15793// zero arguments
    158 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() )
     94template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
    15995{
    16096  res result = 0;
     
    166102  return result;
    167103};
    168 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const )
     104template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
    169105{
    170106  res result = 0;
     
    176112  return result;
    177113};
    178 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
     114// one argument
     115template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
    179116{
    180117  res result = 0;
     
    182119  while (Walker->next != end) {
    183120    Walker = Walker->next;
    184     result += (Walker->*f)();
     121    result += (Walker->*f)(t);
    185122  }
    186123  return result;
    187124};
    188 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
     125template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
    189126{
    190127  res result = 0;
     
    192129  while (Walker->next != end) {
    193130    Walker = Walker->next;
    194     result += (Walker->*f)();
     131    result += (Walker->*f)(t);
    195132  }
    196133  return result;
    197134};
     135
     136
     137// ================== Acting with each Atoms on same molecule ========================== //
     138
     139// zero arguments
     140template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
     141{
     142  atom *Walker = start;
     143  while (Walker->next != end) {
     144    Walker = Walker->next;
     145    (*f)(Walker);
     146  }
     147};
     148template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
     149{
     150  atom *Walker = start;
     151  while (Walker->next != end) {
     152    Walker = Walker->next;
     153    (*f)(Walker);
     154  }
     155};
     156
     157// ================== Acting with each Atoms on copy molecule ========================== //
     158
     159// zero arguments
     160template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
     161{
     162  atom *Walker = start;
     163  while (Walker->next != end) {
     164    Walker = Walker->next;
     165    (copy->*f)(Walker);
     166  }
     167};
     168template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
     169{
     170  atom *Walker = start;
     171  while (Walker->next != end) {
     172    Walker = Walker->next;
     173    (copy->*f)(Walker);
     174  }
     175};
     176
     177// ================== Acting with each Atoms on copy molecule if true ========================== //
     178
     179// zero arguments
     180template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
     181{
     182  atom *Walker = start;
     183  while (Walker->next != end) {
     184    Walker = Walker->next;
     185    if ((Walker->*condition)())
     186      (copy->*f)(Walker);
     187  }
     188};
     189template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
     190{
     191  atom *Walker = start;
     192  while (Walker->next != end) {
     193    Walker = Walker->next;
     194    if ((Walker->*condition)())
     195      (copy->*f)(Walker);
     196  }
     197};
     198template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
     199{
     200  atom *Walker = start;
     201  while (Walker->next != end) {
     202    Walker = Walker->next;
     203    if ((Walker->*condition)())
     204      (copy->*f)(Walker);
     205  }
     206};
     207template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
     208{
     209  atom *Walker = start;
     210  while (Walker->next != end) {
     211    Walker = Walker->next;
     212    if ((Walker->*condition)())
     213      (copy->*f)(Walker);
     214  }
     215};
    198216// one argument
    199 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t )
    200 {
    201   res result = 0;
    202   atom *Walker = start;
    203   while (Walker->next != end) {
    204     Walker = Walker->next;
    205     result += (Walker->*f)(t);
    206   }
    207   return result;
    208 };
    209 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t )
    210 {
    211   res result = 0;
    212   atom *Walker = start;
    213   while (Walker->next != end) {
    214     Walker = Walker->next;
    215     result += (Walker->*f)(t);
    216   }
    217   return result;
    218 };
    219 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
    220 {
    221   res result = 0;
    222   atom *Walker = start;
    223   while (Walker->next != end) {
    224     Walker = Walker->next;
    225     result += (Walker->*f)(t);
    226   }
    227   return result;
    228 };
    229 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
    230 {
    231   res result = 0;
    232   atom *Walker = start;
    233   while (Walker->next != end) {
    234     Walker = Walker->next;
    235     result += (Walker->*f)(t);
    236   }
    237   return result;
    238 };
    239 
    240 
    241 // ================== Acting with each Atoms on same molecule ========================== //
     217template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
     218{
     219  atom *Walker = start;
     220  while (Walker->next != end) {
     221    Walker = Walker->next;
     222    if ((Walker->*condition)(t))
     223      (copy->*f)(Walker);
     224  }
     225};
     226template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
     227{
     228  atom *Walker = start;
     229  while (Walker->next != end) {
     230    Walker = Walker->next;
     231    if ((Walker->*condition)(t))
     232      (copy->*f)(Walker);
     233  }
     234};
     235template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
     236{
     237  atom *Walker = start;
     238  while (Walker->next != end) {
     239    Walker = Walker->next;
     240    if ((Walker->*condition)(t))
     241      (copy->*f)(Walker);
     242  }
     243};
     244template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
     245{
     246  atom *Walker = start;
     247  while (Walker->next != end) {
     248    Walker = Walker->next;
     249    if ((Walker->*condition)(t))
     250      (copy->*f)(Walker);
     251  }
     252};
     253// two arguments
     254template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
     255{
     256  atom *Walker = start;
     257  while (Walker->next != end) {
     258    Walker = Walker->next;
     259    if ((Walker->*condition)(t,u))
     260      (copy->*f)(Walker);
     261  }
     262};
     263template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
     264{
     265  atom *Walker = start;
     266  while (Walker->next != end) {
     267    Walker = Walker->next;
     268    if ((Walker->*condition)(t,u))
     269      (copy->*f)(Walker);
     270  }
     271};
     272template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
     273{
     274  atom *Walker = start;
     275  while (Walker->next != end) {
     276    Walker = Walker->next;
     277    if ((Walker->*condition)(t,u))
     278      (copy->*f)(Walker);
     279  }
     280};
     281template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
     282{
     283  atom *Walker = start;
     284  while (Walker->next != end) {
     285    Walker = Walker->next;
     286    if ((Walker->*condition)(t,u))
     287      (copy->*f)(Walker);
     288  }
     289};
     290// three arguments
     291template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
     292{
     293  atom *Walker = start;
     294  while (Walker->next != end) {
     295    Walker = Walker->next;
     296    if ((Walker->*condition)(t,u,v))
     297      (copy->*f)(Walker);
     298  }
     299};
     300template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
     301{
     302  atom *Walker = start;
     303  while (Walker->next != end) {
     304    Walker = Walker->next;
     305    if ((Walker->*condition)(t,u,v))
     306      (copy->*f)(Walker);
     307  }
     308};
     309template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
     310{
     311  atom *Walker = start;
     312  while (Walker->next != end) {
     313    Walker = Walker->next;
     314    if ((Walker->*condition)(t,u,v))
     315      (copy->*f)(Walker);
     316  }
     317};
     318template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
     319{
     320  atom *Walker = start;
     321  while (Walker->next != end) {
     322    Walker = Walker->next;
     323    if ((Walker->*condition)(t,u,v))
     324      (copy->*f)(Walker);
     325  }
     326};
     327
     328// ================== Acting on all Atoms ========================== //
    242329
    243330// zero arguments
    244 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *))
    245 {
    246   atom *Walker = start;
    247   while (Walker->next != end) {
    248     Walker = Walker->next;
    249     (*f)(Walker);
    250   }
    251 };
    252 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const)
    253 {
    254   atom *Walker = start;
    255   while (Walker->next != end) {
    256     Walker = Walker->next;
    257     (*f)(Walker);
    258   }
    259 };
    260 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
    261 {
    262   atom *Walker = start;
    263   while (Walker->next != end) {
    264     Walker = Walker->next;
    265     (*f)(Walker);
    266   }
    267 };
    268 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
    269 {
    270   atom *Walker = start;
    271   while (Walker->next != end) {
    272     Walker = Walker->next;
    273     (*f)(Walker);
    274   }
    275 };
    276 
    277 // ================== Acting with each Atoms on copy molecule ========================== //
    278 
    279 // zero arguments
    280 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy)
    281 {
    282   atom *Walker = start;
    283   while (Walker->next != end) {
    284     Walker = Walker->next;
    285     (copy->*f)(Walker);
    286   }
    287 };
    288 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const , molecule *copy)
    289 {
    290   atom *Walker = start;
    291   while (Walker->next != end) {
    292     Walker = Walker->next;
    293     (copy->*f)(Walker);
    294   }
    295 };
    296 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
    297 {
    298   atom *Walker = start;
    299   while (Walker->next != end) {
    300     Walker = Walker->next;
    301     (copy->*f)(Walker);
    302   }
    303 };
    304 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
    305 {
    306   atom *Walker = start;
    307   while (Walker->next != end) {
    308     Walker = Walker->next;
    309     (copy->*f)(Walker);
    310   }
    311 };
    312 
    313 // ================== Acting with each Atoms on copy molecule if true ========================== //
    314 
    315 // zero arguments
    316 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () )
    317 {
    318   atom *Walker = start;
    319   while (Walker->next != end) {
    320     Walker = Walker->next;
    321     if ((Walker->*condition)())
    322       (copy->*f)(Walker);
     331template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
     332{
     333  atom *Walker = start;
     334  while (Walker->next != end) {
     335    Walker = Walker->next;
     336    (Walker->*f)();
     337  }
     338};
     339template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
     340{
     341  atom *Walker = start;
     342  while (Walker->next != end) {
     343    Walker = Walker->next;
     344    (Walker->*f)();
    323345  }
    324346};
    325347// one argument
    326 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t )
    327 {
    328   atom *Walker = start;
    329   while (Walker->next != end) {
    330     Walker = Walker->next;
    331     if ((Walker->*condition)(t))
    332       (copy->*f)(Walker);
    333   }
    334 };
    335 // two arguments
    336 template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u )
    337 {
    338   atom *Walker = start;
    339   while (Walker->next != end) {
    340     Walker = Walker->next;
    341     if ((Walker->*condition)(t,u))
    342       (copy->*f)(Walker);
    343   }
    344 };
    345 // three arguments
    346 template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v )
    347 {
    348   atom *Walker = start;
    349   while (Walker->next != end) {
    350     Walker = Walker->next;
    351     if ((Walker->*condition)(t,u,v))
    352       (copy->*f)(Walker);
    353   }
    354 };
    355 
    356 // ================== Acting on all Atoms ========================== //
    357 
    358 // zero arguments
    359 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)())
    360 {
    361   atom *Walker = start;
    362   while (Walker->next != end) {
    363     Walker = Walker->next;
    364     (Walker->*f)();
    365   }
    366 };
    367 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const)
    368 {
    369   atom *Walker = start;
    370   while (Walker->next != end) {
    371     Walker = Walker->next;
    372     (Walker->*f)();
    373   }
    374 };
    375 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
    376 {
    377   atom *Walker = start;
    378   while (Walker->next != end) {
    379     Walker = Walker->next;
    380     (Walker->*f)();
    381   }
    382 };
    383 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
    384 {
    385   atom *Walker = start;
    386   while (Walker->next != end) {
    387     Walker = Walker->next;
    388     (Walker->*f)();
    389   }
    390 };
    391 // one argument
    392 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t )
     348template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    393349{
    394350  atom *Walker = start;
     
    398354  }
    399355};
    400 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t )
     356template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    401357{
    402358  atom *Walker = start;
     
    406362  }
    407363};
    408 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    409 {
    410   atom *Walker = start;
    411   while (Walker->next != end) {
    412     Walker = Walker->next;
    413     (Walker->*f)(t);
    414   }
    415 };
    416 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    417 {
    418   atom *Walker = start;
    419   while (Walker->next != end) {
    420     Walker = Walker->next;
    421     (Walker->*f)(t);
    422   }
    423 };
    424364// two argument
    425 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u )
     365template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    426366{
    427367  atom *Walker = start;
     
    431371  }
    432372};
    433 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u )
     373template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    434374{
    435375  atom *Walker = start;
     
    439379  }
    440380};
    441 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    442 {
    443   atom *Walker = start;
    444   while (Walker->next != end) {
    445     Walker = Walker->next;
    446     (Walker->*f)(t, u);
    447   }
    448 };
    449 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    450 {
    451   atom *Walker = start;
    452   while (Walker->next != end) {
    453     Walker = Walker->next;
    454     (Walker->*f)(t, u);
    455   }
    456 };
    457381// three argument
    458 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v)
     382template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
    459383{
    460384  atom *Walker = start;
     
    464388  }
    465389};
    466 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v)
     390template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
    467391{
    468392  atom *Walker = start;
     
    472396  }
    473397};
    474 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
    475 {
    476   atom *Walker = start;
    477   while (Walker->next != end) {
    478     Walker = Walker->next;
    479     (Walker->*f)(t, u, v);
    480   }
    481 };
    482 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
    483 {
    484   atom *Walker = start;
    485   while (Walker->next != end) {
    486     Walker = Walker->next;
    487     (Walker->*f)(t, u, v);
    488   }
    489 };
    490398// four arguments
    491 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w)
     399template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
    492400{
    493401  atom *Walker = start;
     
    497405  }
    498406};
    499 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w)
     407template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
    500408{
    501409  atom *Walker = start;
     
    505413  }
    506414};
    507 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
    508 {
    509   atom *Walker = start;
    510   while (Walker->next != end) {
    511     Walker = Walker->next;
    512     (Walker->*f)(t, u, v, w);
    513   }
    514 };
    515 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
    516 {
    517   atom *Walker = start;
    518   while (Walker->next != end) {
    519     Walker = Walker->next;
    520     (Walker->*f)(t, u, v, w);
    521   }
    522 };
    523415
    524416// ===================== Accessing arrays indexed by some integer for each atom ======================
    525417
    526418// for atom ints
    527 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) )
     419template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
    528420{
    529421  atom *Walker = start;
     
    534426  }
    535427};
    536 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value )
     428template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
    537429{
    538430  atom *Walker = start;
     
    542434  }
    543435};
    544 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value )
     436template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
    545437{
    546438  atom *Walker = start;
     
    551443};
    552444// for element ints
    553 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) )
     445template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
    554446{
    555447  atom *Walker = start;
     
    560452  }
    561453};
    562 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value )
     454template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
    563455{
    564456  atom *Walker = start;
     
    568460  }
    569461};
    570 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value )
     462template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
    571463{
    572464  atom *Walker = start;
     
    577469};
    578470
    579 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value )
     471template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
    580472{
    581473  atom *Walker = start;
     
    585477  }
    586478};
    587 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect )
     479template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
     480{
     481  atom *Walker = start;
     482  while (Walker->next != end) {
     483    Walker = Walker->next;
     484    array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     485  }
     486};
     487template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
    588488{
    589489  atom *Walker = start;
     
    593493  }
    594494};
    595 
    596 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value )
     495template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
     496{
     497  atom *Walker = start;
     498  while (Walker->next != end) {
     499    Walker = Walker->next;
     500    array[(Walker->*index)] = (Walker->*Setor) (vect);
     501  }
     502};
     503template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
    597504{
    598505  atom *Walker = start;
     
    604511};
    605512
    606 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr )
     513template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
    607514{
    608515  atom *Walker = start;
Note: See TracChangeset for help on using the changeset viewer.