GiNaC  1.6.2
remember.h
Go to the documentation of this file.
00001 
00006 /*
00007  *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
00008  *
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  */
00023 
00024 #ifndef GINAC_REMEMBER_H
00025 #define GINAC_REMEMBER_H
00026 
00027 #include <iosfwd>
00028 #include <list>
00029 #include <vector>
00030 
00031 namespace GiNaC {
00032 
00033 class function;
00034 class ex;
00035     
00040 class remember_table_entry {
00041 public:
00042     remember_table_entry(function const & f, ex const & r);
00043     bool is_equal(function const & f) const;
00044     ex get_result() const { return result; }
00045     unsigned long get_last_access() const { return last_access; }
00046     unsigned long get_successful_hits() const { return successful_hits; };
00047 
00048 protected:
00049     unsigned hashvalue;
00050     exvector seq;
00051     ex result;
00052     mutable unsigned long last_access;
00053     mutable unsigned successful_hits;
00054     static unsigned long access_counter;
00055 };    
00056 
00059 class remember_table_list : public std::list<remember_table_entry> {
00060 public:
00061     remember_table_list(unsigned as, unsigned strat);
00062     void add_entry(function const & f, ex const & result);
00063     bool lookup_entry(function const & f, ex & result) const;
00064 protected:
00065     unsigned max_assoc_size;
00066     unsigned remember_strategy;
00067 };
00068 
00083 class remember_table : public std::vector<remember_table_list> {
00084 public:
00085     remember_table();
00086     remember_table(unsigned s, unsigned as, unsigned strat);
00087     bool lookup_entry(function const & f, ex & result) const;
00088     void add_entry(function const & f, ex const & result);
00089     void clear_all_entries();
00090     void show_statistics(std::ostream & os, unsigned level) const;
00091     static std::vector<remember_table> & remember_tables();
00092 protected:
00093     void init_table();
00094     unsigned table_size;
00095     unsigned max_assoc_size;
00096     unsigned remember_strategy;
00097 };      
00098 
00099 } // namespace GiNaC
00100 
00101 #endif // ndef GINAC_REMEMBER_H

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.