diff options
| Commit | 375d3979cef9a204591094b2c102036bbdd08efe (patch) | |
|---|---|---|
| Author | 2022-12-29 10:14:26 +0200 | |
| Committer | 2022-12-29 10:14:26 +0200 | |
| Files | 8a7fa8e8b2bf439d27f284edf2ede9ba0a889b8e | |
| uni-projects-375d3979cef9a204591094b2c102036bbdd08efe.tar uni-projects-375d3979cef9a204591094b2c102036bbdd08efe.tar.gz uni-projects-375d3979cef9a204591094b2c102036bbdd08efe.zip | ||
| Parent | 77df09397e7fc517dd387d8e46d993ad30f69853 (diff) | |
[SDP/P/exa] logic_errors are now thrown, replacing pure strings
1 files changed, 4 insertions, 3 deletions
| -rw-r--r-- | Year 2/Structures and data algorithms/Project/exa/SkipList.hpp | 7 |
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 4821aef..142c58a 100644 --- a/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp +++ b/Year 2/Structures and data algorithms/Project/exa/SkipList.hpp @@ -4,6 +4,7 @@ #include <istream> #include <ostream> #include <deque> +#include <exception> template <class T> class SkipList { @@ -158,7 +159,7 @@ bool SkipList<T>::addSkip(const T& start, const T& end) { template <class T> T SkipList<T>::pop() { if (empty()) - throw "Pop called on empty SkipList!"; + throw std::logic_error("Pop called on empty SkipList!"); T val = head->value; Node* oldHead = head; @@ -171,7 +172,7 @@ T SkipList<T>::pop() { template <class T> T& SkipList<T>::front() { if (empty()) - throw "Front called on empty SkipList!"; + throw std::logic_error("Front called on empty SkipList!"); return head->value; } @@ -179,7 +180,7 @@ T& SkipList<T>::front() { template <class T> T& SkipList<T>::back() { if (empty()) - throw "Back called on empty SkipList!"; + throw std::logic_error("Back called on empty SkipList!"); return tail->value; } |
