Bag  0.91
Public Member Functions | List of all members
BagInterface< ItemType > Class Template Reference

#include <BagInterface.h>

Inheritance diagram for BagInterface< ItemType >:
ArrayBag< ItemType >

Public Member Functions

virtual int getCurrentSize () const =0
virtual bool isEmpty () const =0
virtual bool add (const ItemType &newEntry)=0
virtual bool remove (const ItemType &anEntry)=0
virtual void clear ()=0
virtual int getFrequencyOf (const ItemType &anEntry) const =0
virtual bool contains (const ItemType &anEntry) const =0
virtual std::vector< ItemType > toVector () const =0
virtual ~BagInterface ()

Detailed Description

template<class ItemType>
class BagInterface< ItemType >

Definition at line 11 of file BagInterface.h.

Constructor & Destructor Documentation

template<class ItemType >
virtual BagInterface< ItemType >::~BagInterface ( )
inlinevirtual

Destroys this bag and frees its assigned memory. (See C++ Interlude 2.)

Definition at line 57 of file BagInterface.h.

Member Function Documentation

template<class ItemType >
virtual bool BagInterface< ItemType >::add ( const ItemType &  newEntry)
pure virtual

Adds a new entry to this bag.

Postcondition
If successful, newEntry is stored in the bag and the count of items in the bag has increased by 1.
Parameters
newEntryThe object to be added as a new entry.
Returns
True if addition was successful, or false if not.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual void BagInterface< ItemType >::clear ( )
pure virtual

Removes all entries from this bag.

Postcondition
Bag contains no items, and the count of items is 0.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual bool BagInterface< ItemType >::contains ( const ItemType &  anEntry) const
pure virtual

Tests whether this bag contains a given entry.

Parameters
anEntryThe entry to locate.
Returns
True if bag contains anEntry, or false otherwise.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual int BagInterface< ItemType >::getCurrentSize ( ) const
pure virtual

Gets the current number of entries in this bag.

Returns
The integer number of entries currently in the bag.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual int BagInterface< ItemType >::getFrequencyOf ( const ItemType &  anEntry) const
pure virtual

Counts the number of times a given entry appears in this bag.

Parameters
anEntryThe entry to be counted.
Returns
The number of times anEntry appears in the bag.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual bool BagInterface< ItemType >::isEmpty ( ) const
pure virtual

Sees whether this bag is empty.

Returns
True if the bag is empty, or false if not.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual bool BagInterface< ItemType >::remove ( const ItemType &  anEntry)
pure virtual

Removes one occurrence of a given entry from this bag, if possible.

Postcondition
If successful, anEntry has been removed from the bag and the count of items in the bag has decreased by 1.
Parameters
anEntryThe entry to be removed.
Returns
True if removal was successful, or false if not.

Implemented in ArrayBag< ItemType >.

template<class ItemType >
virtual std::vector<ItemType> BagInterface< ItemType >::toVector ( ) const
pure virtual

Empties and then fills a given vector with all entries that are in this bag.

Returns
A vector containing all the entries in the bag.

Implemented in ArrayBag< ItemType >.


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