From a996283af7c21baaff0e114d58c34db820902c6f Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Sun, 27 Jan 2019 15:37:06 +0000 Subject: Reorganise repo All solvitaire content has been shoved into a subdirectory to tidy up the root of the project. This also means solvitaire is treated similarly to other dependencies of the project, and allows other dependencies to be added easily. There's also a lot of other work done here, such as usign a thread pool library to manage the running of the voters. --- src/main/game/pile.cpp | 92 -------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 src/main/game/pile.cpp (limited to 'src/main/game/pile.cpp') diff --git a/src/main/game/pile.cpp b/src/main/game/pile.cpp deleted file mode 100644 index 23a02af..0000000 --- a/src/main/game/pile.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// -// Created by thecharlesblake on 10/28/17. -// - -#include -#include - -#include "pile.h" - -using namespace std; - -const pile::size_type pile::max_size_type = 255; - -pile::pile(std::vector pv) : pile_vec(pv) { -} - -pile::pile(std::initializer_list il) : pile_vec(il) { -} - -card pile::top_card() const { - assert(!empty()); - return pile_vec.back(); -} - -bool pile::empty() const { - return pile_vec.empty(); -} - -pile::size_type pile::size() const { - return static_cast(pile_vec.size()); -} - -card& pile::operator[] (size_type i) { - return pile_vec[pile_vec.size() - 1 - i]; -} - -card pile::operator[] (size_type i) const { - vector::size_type s = pile_vec.size() - 1 - i; - assert(s < pile_vec.size()); - return pile_vec[s]; -} - -void pile::place(const card c) { - pile_vec.emplace_back(c); -} - -card pile::take() { - assert(!empty()); - card c = top_card(); - pile_vec.pop_back(); - return c; -} - -bool operator==(const pile& a, const pile& b) { - return a.pile_vec == b.pile_vec; -} - -bool operator!=(const pile& a, const pile& b) { - return a.pile_vec != b.pile_vec; -} - -bool operator<(const pile& a, const pile& b) { - if (a.size() == b.size()) { - return a.pile_vec < b.pile_vec; - } else { - return a.size() < b.size(); - } -} - -bool operator>(const pile& a, const pile& b) { - if (a.size() == b.size()) { - return a.pile_vec > b.pile_vec; - } else { - return a.size() > b.size(); - } -} - -bool operator<=(const pile& a, const pile& b) { - if (a.size() == b.size()) { - return a.pile_vec <= b.pile_vec; - } else { - return a.size() <= b.size(); - } -} - -bool operator>=(const pile& a, const pile& b) { - if (a.size() == b.size()) { - return a.pile_vec >= b.pile_vec; - } else { - return a.size() >= b.size(); - } -} -- cgit v1.2.1