mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 21:40:11 +00:00
update IndexedStore::setUp() for multiple datafile support
This commit is contained in:
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…
x
Reference in New Issue
Block a user