31 const std::string & prefix)
33 if (key ==
"" && prefix ==
"")
return true;
35 size_t digitsStart = key.length() - 1;
37 while (
isDigit(key[digitsStart]) && digitsStart) --digitsStart;
39 if (digitsStart < 1 || digitsStart > key.length() - 2 || key[digitsStart] !=
'_')
return false;
43 if (prefix != key.substr(0, digitsStart))
return false;
49 while (
isPrefix(key[prefixEnd]) && prefixEnd < digitsStart) ++prefixEnd;
51 return (prefixEnd == digitsStart);
63 for (i = 0, imax =
size(); i < imax; i++)
66 for (i = 0, imax = str.length(); i < imax; i++)
108 mTable.resize(mSize * 2,
true);
109 memset(mTable.array() + mSize, 0, mSize *
sizeof(
CCopasiObject *));
114 mTable[index] = pObject;
121 while (index >= mSize)
123 mTable.resize(mSize * 2,
true);
124 memset(mTable.array() + mSize, 0,
129 if (mTable[index])
return false;
131 mTable[index] = pObject;
137 if (index < mSize)
return mTable[index];
146 if (!mTable[index])
return false;
148 mTable[index] = NULL;
170 std::map< std::string, CKeyFactory::HashTable >::iterator it =
175 std::pair<std::map< std::string, CKeyFactory::HashTable >::iterator,
bool> ret =
181 std::stringstream key;
182 key << prefix +
"_" << it->second.add(pObject);
189 size_t pos = key.length() - 1;
191 while (
isDigit(key[pos]) && pos) --pos;
193 std::string Prefix = key.substr(0, pos);
194 size_t index = atoi(key.substr(pos + 1).c_str());
196 std::map< std::string, CKeyFactory::HashTable >::iterator it =
201 std::pair<std::map< std::string, CKeyFactory::HashTable >::iterator,
bool> ret =
207 return it->second.addFix(index, pObject);
212 size_t pos = key.length();
214 if (pos == 0)
return false;
218 while (
isDigit(key[pos]) && pos) --pos;
220 std::string Prefix = key.substr(0, pos);
224 if (pos + 1 < key.length())
225 index = atoi(key.substr(pos + 1).c_str());
227 std::map< std::string, CKeyFactory::HashTable >::iterator it =
232 return it->second.remove(index);
237 if (key.length() == 0)
return NULL;
239 size_t pos = key.length() - 1;
241 while (
isDigit(key[pos]) && pos) --pos;
243 std::string Prefix = key.substr(0, pos);
244 size_t index = atoi(key.substr(pos + 1).c_str());
246 std::map< std::string, CKeyFactory::HashTable >::iterator it =
251 return it->second.get(index);
bool remove(const std::string &key)
CVector< CCopasiObject * > mTable
std::map< std::string, HashTable > mKeyTable
static CDecisionVector isDigit
static CDecisionVector isPrefix
CCopasiObject * get(const std::string &key)
static bool isValidKey(const std::string &key, const std::string &prefix="")
bool addFix(const std::string &key, CCopasiObject *pObject)
std::string add(const std::string &prefix, CCopasiObject *pObject)
size_t add(CCopasiObject *pObject)
CCopasiObject * get(const size_t &index)
bool remove(const size_t &index)
bool addFix(const size_t &index, CCopasiObject *pObject)
const bool & operator()(const unsigned char &c) const
virtual ~CDecisionVector()