/* This file is part of cardwords
   (c) 1998 1999 Tobias Peters
   see file COPYING for the copyright terms.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_cardcontainer1dim.hh

#ifndef CARDWORDS_CARDCONTAINER1DIM_HH
#define CARDWORDS_CARDCONTAINER1DIM_HH

#include "cardwords_cardcontainer.hh"
#include <set>
#include "cardwords_iostream.hh"

class CardWords_CardContainer1Dim
  : public CardWords_CardContainer, public set<CardWords_Card*>
// Since every Card has its own place in memory,
// it is possible to compare the pointers directly. This is sufficient
// for a set.
{
public:
  // remove a special card from the container:
  virtual void remove_card (CardWords_Card *);
    
  // add a card to the container:
  virtual void // This one is virtual because the derived class might want to
  add_card (CardWords_Card *); // know what's going on.

  // remove all cards and put them into pile:
  virtual void   clear  (class CardWords_CardContainer1Dim *pile);

  // information about how the space is used:
  size_t free_places     (void) const;
  size_t occupied_places (void) const;
  size_t total_places    (void) const;

  CardWords_CardContainer1Dim (size_t size);

  // the destructor automatically deletes all contained cards:
  virtual ~CardWords_CardContainer1Dim ();

  // these methods are looking if such a card is contained in the container:
  CardWords_Card *
  matching_card (const CardWords_CardBase &) const;
  // Returns an arbitrary matching card with this face value.
  // If no card has the required face value, but there is at least 1 wild-
  // card, returns an arbitrary wildcard.
  // If there is no card with the required face value and no wildcard,
  // returns 0.
  CardWords_Card *
  matching_card (CardWords_Char) const;

  // How many cards with this face value are there ?
  size_t
  get_no_of_matching_cards(CardWords_Char) const;

  // Gets the n'th matching card with the required face value. However,
  // this numbering is arbitrary! But it is at least guaranteed not to
  // change as long as the container does not change. This means
  // get_matching_card(c, 1) returns always the same ('first') card
  // with face value c as long as no cards are added to or removed from
  // the container. 1 <= n_th_match <= get_no_of_matching_cards(). if
  // n_th_match is not inside this intervall, 0 is returned.
  CardWords_Card *
  matching_card (CardWords_Char, size_t n_th_match) const;
  

private:
  size_t sizeOfContainer;
};

ostream & operator << (ostream &, const CardWords_CardContainer1Dim &); 
#endif
