CardSequence Class Reference

#include <cardsequence.h>

Collaboration diagram for CardSequence:

Collaboration graph
[legend]

List of all members.


Detailed Description

This is a sequence of cards. This is generally used to hold a player's hand or the sequence of cards played.

Author:
John Schneiderman

Public Types

typedef deque< Card >
::const_iterator 
const_iterator
typedef deque< Card >::iterator iterator

Public Member Functions

void addCard (const Card &card)
void addCardToFront (const Card &card)
Cardback ()
const Cardback () const
const_iterator begin () const
iterator begin ()
 CardSequence (const Card &card)
 CardSequence ()
void clear ()
const_iterator end () const
iterator end ()
Cardfront ()
const Cardfront () const
bool hasCard (const Card &card) const
bool hasRank (const Card::Rank &rank) const
bool hasSuit (const Card::Suit &suit) const
bool isEmpty () const
CardSequence operator+ (const CardSequence &rhs) const
CardSequenceoperator+= (const CardSequence &rhs)
CardSequence operator- (const CardSequence &rhs) const
CardSequenceoperator-= (const CardSequence &rhs)
bool operator< (const CardSequence &compare) const
bool operator== (const CardSequence &compare) const
Cardoperator[] (int index)
const Cardoperator[] (int index) const
bool removeCard (const Card &card)
int size () const
void sortBySuit ()

Friends

QDebug & operator<< (QDebug &out, const CardSequence &sequence)
QTextStream & operator<< (QTextStream &out, const CardSequence &sequence)
ostream & operator<< (ostream &out, const CardSequence &sequence)
QTextStream & operator>> (QTextStream &in, CardSequence &sequence)
istream & operator>> (istream &in, CardSequence &sequence)

Member Typedef Documentation

Parameters:
const_iterator is an alias to deque<Card>::const_iterator

Parameters:
iterator is an alias to deque<Card>::iterator


Constructor & Destructor Documentation

CardSequence::CardSequence (  ) 

This is the default constructor.

CardSequence::CardSequence ( const Card card  ) 

This is a copy constructor for a single card sequence.


Member Function Documentation

void CardSequence::addCard ( const Card card  ) 

This is used to add a card to the end of a players sequence.

Parameters:
card is the card to add to a players sequence.

void CardSequence::addCardToFront ( const Card card  ) 

This is used to add a card to the beginning of a players sequence.

Parameters:
card is the card to add to a players sequence.

Card & CardSequence::back (  ) 

Gives the last card in the sequence.

Returns:
the last card.

const Card & CardSequence::back (  )  const

Gives the last card in the sequence.

Returns:
the last card.

CardSequence::const_iterator CardSequence::begin (  )  const

Gives a constant iterator to the first card in the sequence.

Returns:
gives an const_iterator to the first card.

CardSequence::iterator CardSequence::begin (  ) 

Gives an iterator to the first card in the sequence.

Returns:
gives an iterator to the first card.

void CardSequence::clear (  ) 

Removes all of the cards from the sequence.

CardSequence::const_iterator CardSequence::end (  )  const

Gives a constant iterator to the end of the cards in the sequence.

Returns:
gives an const_iterator to the end of the cards.

CardSequence::iterator CardSequence::end (  ) 

Gives an iterator to the end of the cards in the sequence.

Returns:
gives an iterator to the end of the cards.

Card & CardSequence::front (  ) 

Gives the first card in the sequence.

Returns:
the first card.

const Card & CardSequence::front (  )  const

Gives the first card in the sequence.

Returns:
the first card.

bool CardSequence::hasCard ( const Card card  )  const

This determines if the sequence has a specific card in it.

Parameters:
card is the card to check to see if it's in the sequence.
Returns:
true if card is in the sequence, false elsewise.

bool CardSequence::hasRank ( const Card::Rank rank  )  const

This determines if the sequence has a specific rank in it.

Parameters:
rank is the rank to search for.
Returns:
true if the rank is found in the sequence, false elsewise.

bool CardSequence::hasSuit ( const Card::Suit suit  )  const

This determines if the sequence has a specific suit in it.

Parameters:
suit is the suit to search for.
Returns:
true if the suit is found in the sequence, false elsewise.

bool CardSequence::isEmpty (  )  const

This determines if the current sequence has no cards in it.

Returns:
true if the sequence is empty or has only invalid cards, false elsewise.

CardSequence CardSequence::operator+ ( const CardSequence rhs  )  const

This creates a combined sequence based on *this and a passed in sequence.

Parameters:
rhs is the card sequence to combine with *this.
Returns:
*this combined with rhs having rhs at the end.

CardSequence & CardSequence::operator+= ( const CardSequence rhs  ) 

This appends a card sequence to the end of *this.

Parameters:
rhs is the card sequence to add to the end of *this.
Returns:
*this.

CardSequence CardSequence::operator- ( const CardSequence rhs  )  const

This removes a sequence from *this.

Parameters:
rhs is the sequence to remove from *this.
Returns:
the result of remove rhs from *this.

CardSequence & CardSequence::operator-= ( const CardSequence rhs  ) 

This removes and assigns the sequence from *this.

Parameters:
rhs is the sequence to remove from *this.
Returns:
*this.

bool CardSequence::operator< ( const CardSequence compare  )  const

Less than operator.

Note:
We only compare the sizes of the card sequences.
Parameters:
compare is the card sequence to compare.
Returns:
true if the sequence of cards in *this is less than the sequence of cards in compare.

bool CardSequence::operator== ( const CardSequence compare  )  const

Equivalent operator.

Note:
The card sequence order does matter in determining equivalence.
Parameters:
compare is the card sequence to compare.
Returns:
true if the sequence of cards in *this is the same as the sequence of cards in compare.

Card & CardSequence::operator[] ( int  index  ) 

Random accessor for the sequence.

Parameters:
index is the card to get from the sequence.
Exceptions:
KardsGTError if index is out of range.
Returns:
a reference to the card requested.

const Card & CardSequence::operator[] ( int  index  )  const

Random accessor for the card sequence.

Parameters:
index is the card to get from the sequence.
Exceptions:
KardsGTError if index is out of range.
Returns:
the card requested.

bool CardSequence::removeCard ( const Card card  ) 

This is used to remove the first instance of a card from a players sequence.

Parameters:
card is the card to remove from a players sequence.
Returns:
true if the card was successful in its attempt to remove the card, false elsewise.

int CardSequence::size (  )  const

Gives the current number of cards in the sequence.

Returns:
the number of cards.

void CardSequence::sortBySuit (  ) 

Sorts all the cards first by suit then by rank.


Friends And Related Function Documentation

QDebug& operator<< ( QDebug &  out,
const CardSequence sequence 
) [friend]

A stream insertion operator that will writes out a card sequence.

Parameters:
out this is the buffer to write the card sequence to.
sequence is the card sequence to write out.
Returns:
a reference to out.
Note:
Each of the cards are separated by white space, and the last card is followed by an empty card.

QTextStream& operator<< ( QTextStream &  out,
const CardSequence sequence 
) [friend]

A stream insertion operator that will writes out a card sequence.

Parameters:
out this is the buffer to write the card sequence to.
sequence is the card sequence to write out.
Returns:
a reference to out.
Note:
Each of the cards are separated by white space, and the last card is followed by an empty card.

ostream& operator<< ( ostream &  out,
const CardSequence sequence 
) [friend]

A stream insertion operator that writes out a card sequence.

Parameters:
out this is the buffer to write the card sequence to.
sequence is the card sequence to write out.
Returns:
a reference to out.
Note:
Each of the cards are separated by white space.

QTextStream& operator>> ( QTextStream &  in,
CardSequence sequence 
) [friend]

A stream extraction operator that will read in a card sequence.

Parameters:
in this is the buffer to read the card sequence from.
sequence is the card sequence to read into.
Returns:
a reference to in.
Note:
Each card to read in is assumed to be separated by white space, and continues to read until an empty card is read in.

istream& operator>> ( istream &  in,
CardSequence sequence 
) [friend]

A stream extraction operator that will read in a card sequence.

Parameters:
in this is the buffer to read the card sequence from.
sequence is the card sequence to read into.
Returns:
a reference to in.
Note:
Each card to read in is assumed to be separated by white space.


The documentation for this class was generated from the following files:

Generated on Tue Aug 12 23:24:01 2008 for KardsGT by  doxygen 1.5.5