Added version number to files; IndexMap now works with GetMember

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@40 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-19 21:01:17 +00:00
parent 440cec2f8c
commit c15bc94ee7
13 changed files with 115 additions and 25 deletions
+11 -1
View File
@@ -41,7 +41,8 @@ class IndexMap : private vector<Value> {
void init(const vector<Key>& keys) {
if (!this->empty()) return;
this->reserve(keys.size());
FOR_EACH_CONST(key, keys) {
for(vector<Key>::const_iterator it = keys.begin() ; it != keys.end() ; ++it) {
const Key& key = *it;
assert(key);
if (key->index >= this->size()) this->resize(key->index + 1);
init_object(key, (*this)[key->index]);
@@ -68,6 +69,15 @@ class IndexMap : private vector<Value> {
return key->index < this.size() && get_key((*this)[key->index]) == key
}
/// Find a value given the key name, return an iterator
template <typename Name>
const_iterator find(const Name& key) const {
for(vector<Value>::const_iterator it = begin() ; it != end() ; ++it) {
if (get_key_name(*it) == key) return it;
}
return end();
}
private:
using vector<Value>::operator [];
};