7 #include <boost/thread.hpp>
13 bool operator()(
const char *id1,
const char *id2)
const
14 {
return std::strcmp(id1, id2) < 0; }
21 inline const char *
findOrInsert(
const char *
string)
throw();
24 typedef std::multiset<const char *, StringLess> IdSet;
27 static std::allocator<char> stringAllocator;
32 std::allocator<char> IdCache::stringAllocator;
36 for(std::multiset<const char*, StringLess>::iterator iter =
37 idSet.begin(); iter != idSet.end(); iter++)
38 stringAllocator.deallocate(const_cast<char*>(*iter),
44 boost::mutex::scoped_lock scoped_lock(
mutex);
46 IdSet::iterator pos = idSet.lower_bound(
string);
47 if (pos != idSet.end() && std::strcmp(*pos,
string) == 0)
50 std::size_t
size = std::strlen(
string) + 1;
51 char *unique = stringAllocator.allocate(size);
52 std::memcpy(unique,
string, size);
54 idSet.insert(pos, unique);
59 namespace PhysicsTools {
63 static IdCache atomicIdCache;
static boost::mutex mutex
Value & findOrInsert(std::map< Key, Value > &m, Key const &k)
tuple size
Write out results.