1 /********************************************************************** 2 * 3 * FreeDoko a Doppelkopf-Game 4 * 5 * Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * You can find this license in the file 'gpl.txt'. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA 22 * 23 * Contact: 24 * Diether Knof dknof@posteo.de 25 * 26 **********************************************************************/ 27 28 // included by trickpile.h 29 30 #pragma once 31 32 class TrickPile; 33 34 class TrickPileIterator : public std::iterator<std::output_iterator_tag, Trick> { 35 friend class TrickPile; 36 public: 37 using iterator_category = std::forward_iterator_tag; 38 private: 39 TrickPileIterator() = delete; 40 TrickPileIterator(TrickPile& tricks, unsigned t); 41 42 public: 43 Trick& operator*(); 44 Trick const& operator*() const; 45 Trick* operator->(); 46 Trick const* operator->() const; 47 TrickPileIterator& operator++(); 48 bool operator!=(TrickPileIterator const& i) const; 49 private: 50 TrickPile* const tricks_ = nullptr; 51 size_t t_ = 0; 52 }; // TrickPileIterator 53 54 class TrickPileConstIterator : public std::iterator<std::output_iterator_tag, Trick> { 55 friend class TrickPile; 56 public: 57 using iterator_category = std::forward_iterator_tag; 58 private: 59 TrickPileConstIterator() = delete; 60 TrickPileConstIterator(TrickPile const& tricks, unsigned t); 61 62 public: 63 TrickPileConstIterator(TrickPileIterator i); 64 Trick const& operator*() const; 65 Trick const* operator->() const; 66 TrickPileConstIterator& operator++(); 67 bool operator!=(TrickPileConstIterator const& i) const; 68 private: 69 TrickPile const* const tricks_ = nullptr; 70 size_t t_ = 0; 71 }; // TrickPileConstIterator 72