diff options
| Commit | f3ee1a0ea95ebbd08dd3dcfe341c649d8ce4a8c1 (patch) | |
|---|---|---|
| Author | 2023-01-07 19:46:08 +0200 | |
| Committer | 2023-01-07 19:46:08 +0200 | |
| Files | f6e080e7a9a42f35f2eda53694ad8d60f8a67a8b | |
| uni-projects-f3ee1a0ea95ebbd08dd3dcfe341c649d8ce4a8c1.tar uni-projects-f3ee1a0ea95ebbd08dd3dcfe341c649d8ce4a8c1.tar.gz uni-projects-f3ee1a0ea95ebbd08dd3dcfe341c649d8ce4a8c1.zip | ||
| Parent | 3e4a9412564187665ff1a1ffa96bbeb8c093dadd (diff) | |
[SDP/P/exa] Added sort of unsorted given cities to visit
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; |
