mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
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:
+11
-1
@@ -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 [];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user