X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fremember.cpp;h=4218a6ea917a1002973838d9f60d032479c25ea4;hp=404c7c81bf0c1823c821521ac3a3f5885648b1e1;hb=c1285bb62f3a86454ca26260cf8b4352238a1fc5;hpb=57b66d879a72c007eabe081420de11757b5bcf90 diff --git a/ginac/remember.cpp b/ginac/remember.cpp index 404c7c81..4218a6ea 100644 --- a/ginac/remember.cpp +++ b/ginac/remember.cpp @@ -4,7 +4,7 @@ * in GiNaC functions */ /* - * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,9 +27,7 @@ #include "utils.h" #include "remember.h" -#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_NAMESPACE_GINAC ////////// // class remember_table_entry @@ -46,14 +44,15 @@ bool remember_table_entry::is_equal(function const & f) const { GINAC_ASSERT(f.seq.size()==seq.size()); if (f.gethash()!=hashvalue) return false; - for (unsigned i=0; i=max_assoc_size)) { // table is full, we must delete an older entry GINAC_ASSERT(size()>0); // there must be at least one entry @@ -122,11 +121,13 @@ void remember_table_list::add_entry(function const & f, ex const & result) bool remember_table_list::lookup_entry(function const & f, ex & result) const { - for (const_iterator cit=begin(); cit!=end(); ++cit) { - if ((*cit).is_equal(f)) { - result = (*cit).get_result(); + const_iterator i = begin(), iend = end(); + while (i != iend) { + if (i->is_equal(f)) { + result = i->get_result(); return true; } + ++i; } return false; } @@ -147,7 +148,7 @@ remember_table::remember_table(unsigned s, unsigned as, unsigned strat) { // we keep max_assoc_size and remember_strategy if we need to clear // all entries - + // use some power of 2 next to s table_size = 1 << log2(s); init_table(); @@ -167,25 +168,23 @@ void remember_table::add_entry(function const & f, ex const & result) operator[](entry).add_entry(f,result); } -void remember_table::clear_all_entries(void) +void remember_table::clear_all_entries() { clear(); init_table(); } -void remember_table::init_table(void) +void remember_table::init_table() { reserve(table_size); for (unsigned i=0; i & remember_table::remember_tables(void) +std::vector & remember_table::remember_tables() { static std::vector * rt = new std::vector; return *rt; } -#ifndef NO_NAMESPACE_GINAC } // namespace GiNaC -#endif // ndef NO_NAMESPACE_GINAC