12 template <
typename ItemType,
typename KeyType,
typename IndexType, IndexType Sentinel>
13 void rearrage(ItemType* items, std::pair< KeyType,IndexType>* indices,
size_t count)
15 for (
size_t i = 0; i < count; ++i)
17 if (indices[i].second == -1)
continue;
20 ItemType tempItem = items[i];
22 while (indices[j].second != Sentinel)
24 size_t next_j = indices[j].second;
28 indices[j].second = Sentinel;
33 items[j] = items[next_j];
34 indices[j].second = Sentinel;