added: Pattern::CacheFunctions(Functions<StreamType> & fun)

you can cache all functions (their addresses) in the pattern

changed: now we have two methods for generating content:
       Generator<>::Generate(StreamType & o, Pattern & p, Functions<StreamType> & f);
       similar like previous -- Set(...) methods were removed as well as the second ctor 

       and a second one:
       Generate(StreamType & o, Pattern & p);
       without functions, the functions should be cached beforehand in the pattern
       by calling CacheFunctions() method on the pattern
       this gives O(1) complexity when looking for a specific function
       previously was O(log n) 
       


git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@329 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-11-25 22:39:58 +00:00
parent 5108495540
commit 0b09b5454f
6 changed files with 195 additions and 152 deletions

View File

@@ -40,7 +40,7 @@
#include <map>
#include "funinfo.h"
#include "stringconv.h"
namespace Ezc
@@ -87,8 +87,7 @@ public:
bool Find(const std::string & key, Function ** fun);
bool Find(const std::wstring & key, Function ** fun);
void Clear();
size_t Size();
size_t Size() const;
private:
typedef std::map<std::wstring, Function> FunctionsTable;
@@ -99,9 +98,6 @@ private:
template<class StreamType>
Functions<StreamType>::Function::Function()
{
@@ -246,13 +242,15 @@ void Functions<StreamType>::Clear()
}
template<class StreamType>
size_t Functions<StreamType>::Size()
size_t Functions<StreamType>::Size() const
{
return functions_tab.size();
}
} // namespace Ezc