Some more data types; dynamic arguments

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@5 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-01 19:40:39 +00:00
parent 50b22e9478
commit 331423bd07
27 changed files with 431 additions and 95 deletions
+5 -5
View File
@@ -16,7 +16,7 @@
/// A kind of map of K->V, with the following properties:
/** - K must have a unique member ->index of type UInt
* - There must exist a function initObject(K, V&)
* that stores a new V object for a given key in v
* that stores a new V object for a given key in the reference
* - O(1) inserts and lookups
*/
template <typename Key, typename Value>
@@ -35,10 +35,10 @@ class IndexMap : private vector<Value> {
void init(const vector<Key>& keys) {
if (!this->empty()) return;
this->reserve(keys.size());
FOR_EACH(it, keys) {
Key& k = *it;
if (k->index >= this->size()) this->resize(k->index + 1);
initObject(k, (*this)[k->index]);
FOR_EACH_CONST(key, keys) {
assert(key);
if (key->index >= this->size()) this->resize(key->index + 1);
initObject(key, (*this)[key->index]);
}
}