update IndexedStore::setUp() for multiple datafile support

actorid
greye 12 years ago
parent 1051fa51a7
commit cfccf0981d

@ -872,7 +872,28 @@ namespace MWWorld
} }
void setUp() { void setUp() {
std::sort(mStatic.begin(), mStatic.end(), Compare()); /// \note This method sorts indexed values for further
/// searches. Every loaded item is present in storage, but
/// latest loaded shadows any previous while searching.
/// If memory cost will be too high, it is possible to remove
/// unused values.
Compare cmp;
std::stable_sort(mStatic.begin(), mStatic.end(), cmp);
typename std::vector<T>::iterator first, next;
next = first = mStatic.begin();
while (first != mStatic.end() && ++next != mStatic.end()) {
while (next != mStatic.end() && !cmp(*first, *next)) {
++next;
}
if (first != --next) {
std::swap(*first, *next);
}
first = ++next;
}
} }
const T *search(int index) const { const T *search(int index) const {

Loading…
Cancel
Save