diff options
1 files changed, 11 insertions, 0 deletions
| -rw-r--r-- | Year 2/Structures and data algorithms/Project/exa/SkipList.hpp | 11 |
diff --git a/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp b/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp index 6a73533..ecc0c96 100644 --- a/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp +++ b/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp @@ -108,6 +108,17 @@ bool SkipList<T>::recShortSublist(Node* current, std::deque<T>& search, std::deq template <class T> std::deque<T> SkipList<T>::shortestSublistIncluding(std::deque<T>& locs) { + // Sort locs + for (Node* i = head; i != nullptr; i = i->next) { + for (auto j = locs.begin(), end = locs.end(); j != end; ++j) { + if (*j == i->value) { + locs.erase(j); + locs.push_back(i->value); + break; + } + } + } + std::deque<T> out; recShortSublist(head, locs, out); return out; |
