From f3ee1a0ea95ebbd08dd3dcfe341c649d8ce4a8c1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 Jan 2023 19:46:08 +0200 Subject: [SDP/P/exa] Added sort of unsorted given cities to visit --- .../Structures and data algorithms/Project/exa/SkipList.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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::recShortSublist(Node* current, std::deque& search, std::deq template std::deque SkipList::shortestSublistIncluding(std::deque& 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 out; recShortSublist(head, locs, out); return out; -- cgit v1.3.1-23-gd82d