/* ---------------------------------------------------------------- */ /* Copyright 2004 (c) by RWTH Aachen - Lehrstuhl fuer Informatik VI */ /* Richard Zens */ /* ---------------------------------------------------------------- */ #ifndef moses_UniqueObject_h #define moses_UniqueObject_h #include #include template T const* uniqueObject(const T& x,int mode=0) { typedef std::set Pool; static Pool pool; static size_t Size=0; if(mode==0) { std::pair p=pool.insert(x); if(p.second && (++Size%100000==0)) std::cerr<<"uniqueObjects -- size: "< class UniqueObjectManager { public: typedef T Object; private: typedef std::set Pool; Pool pool; public: UniqueObjectManager() {} void clear() { pool.clear(); } size_t size() const { return pool.size(); } Object const * operator()(const Object& x) { #ifdef DEBUG std::pair p=pool.insert(x); if(p.second && (size()%100000==0)) std::cerr<<"uniqueObjects -- size: "<