Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
Loading...
Searching...
No Matches
Public Member Functions
dsac::array::Scoreboard Class Reference

Class for storing high scores ordered within an array. More...

#include <scoreboard.h>

Collaboration diagram for dsac::array::Scoreboard:
Collaboration graph

Public Member Functions

 Scoreboard (int cap=10)
 
void add (int score, const std::string &name)
 
GameEntry remove (int i)
 
int get_capacity () const
 
int get_num_entries () const
 
const GameEntryget_entry (int i) const
 
 Scoreboard (const Scoreboard &other)
 Copy constructor.
 
Scoreboardoperator= (const Scoreboard &other)
 Copy assignment.
 
 Scoreboard (Scoreboard &&other)
 Move constructor.
 
Scoreboardoperator= (Scoreboard &&other)
 Move assignment.
 
 ~Scoreboard ()
 destructor
 

Detailed Description

Class for storing high scores ordered within an array.

Constructor & Destructor Documentation

◆ Scoreboard() [1/3]

dsac::array::Scoreboard::Scoreboard ( int  cap = 10)
inline

Constructs an empty scoreboard with the given capacity for storing entries The default capacity is 10.

Parameters
capthe desired capacity for the scoreboard

◆ Scoreboard() [2/3]

dsac::array::Scoreboard::Scoreboard ( const Scoreboard other)
inline

Copy constructor.

◆ Scoreboard() [3/3]

dsac::array::Scoreboard::Scoreboard ( Scoreboard &&  other)
inline

Move constructor.

◆ ~Scoreboard()

dsac::array::Scoreboard::~Scoreboard ( )
inline

destructor

Member Function Documentation

◆ add()

void dsac::array::Scoreboard::add ( int  score,
const std::string &  name 
)

Attempts to add a new score to the scoreboard (if it is high enough)

Parameters
intscore
stringname

◆ get_capacity()

int dsac::array::Scoreboard::get_capacity ( ) const
inline

Returns the capacity of the scoreboard

Returns
the capacity of the scoreboard

◆ get_entry()

const GameEntry & dsac::array::Scoreboard::get_entry ( int  i) const
inline

Returns a reference to the entry at index i

Parameters
iindex such that 0 <= i < getNumEntries()
Returns
the entry at index i

◆ get_num_entries()

int dsac::array::Scoreboard::get_num_entries ( ) const
inline

Returns the number of current entries stored

Returns
the number of current entries stored

◆ operator=() [1/2]

Scoreboard & dsac::array::Scoreboard::operator= ( const Scoreboard other)
inline

Copy assignment.

◆ operator=() [2/2]

Scoreboard & dsac::array::Scoreboard::operator= ( Scoreboard &&  other)
inline

Move assignment.

◆ remove()

GameEntry dsac::array::Scoreboard::remove ( int  i)

Removes and returns the scoreboard entry at index i

Parameters
iindex within scoreboard
Exceptions
out_of_rangeif not 0 <= i < get_num_entries()
Returns
GameEntry instance

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