From b6e654657da058e9a438ec4583fac8028758dfb4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 29 Dec 2022 09:09:41 +0200 Subject: [SDP/P/exa] Removed hard coded example and added user input reading --- Year 2/Structures and data algorithms/Project/exa/SkipList.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Year 2/Structures and data algorithms/Project/exa/SkipList.hpp') 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 125013b..4821aef 100644 --- a/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp +++ b/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp @@ -32,6 +32,7 @@ public: bool addSkip(const T&, const T&); T pop(); T& front(); + T& back(); unsigned size(); bool empty(); @@ -175,6 +176,14 @@ T& SkipList::front() { return head->value; } +template +T& SkipList::back() { + if (empty()) + throw "Back called on empty SkipList!"; + + return tail->value; +} + template unsigned SkipList::size() { return listSize; -- cgit v1.3.1-26-gb76a