diff options
| author | Tom Harley | 2019-01-27 15:37:06 +0000 |
|---|---|---|
| committer | Tom Harley | 2019-01-27 15:37:06 +0000 |
| commit | a996283af7c21baaff0e114d58c34db820902c6f (patch) | |
| tree | 2fe5b6f7a800d4a7b8a65ee345f8c98aa138e36b /src/main/game/pile.cpp | |
| parent | Split code into 3 files (diff) | |
| download | metasol-a996283af7c21baaff0e114d58c34db820902c6f.tar.gz metasol-a996283af7c21baaff0e114d58c34db820902c6f.zip | |
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.
Diffstat (limited to 'src/main/game/pile.cpp')
| -rw-r--r-- | src/main/game/pile.cpp | 92 |
1 files changed, 0 insertions, 92 deletions
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 <vector> -#include <ostream> - -#include "pile.h" - -using namespace std; - -const pile::size_type pile::max_size_type = 255; - -pile::pile(std::vector<card> pv) : pile_vec(pv) { -} - -pile::pile(std::initializer_list<card> 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<uint8_t>(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<card>::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(); - } -} |
