CISC 2200 Project 2
Public Member Functions | List of all members
BagInterface< ItemType > Class Template Referenceabstract
Inheritance diagram for BagInterface< ItemType >:
Inheritance graph
[legend]

Public Member Functions

virtual int getCurrentSize () const =0
 Gets the current number of entries in this bag. More...
 
virtual bool isEmpty () const =0
 Sees whether this bag is empty. More...
 
virtual bool add (const ItemType &newEntry)=0
 Adds a new entry to this bag. More...
 
virtual bool remove (const ItemType &anEntry)=0
 Removes one occurrence of a given entry from this bag, if possible. More...
 
virtual void clear ()=0
 Removes all entries from this bag. More...
 
virtual int getFrequencyOf (const ItemType &anEntry) const =0
 Counts the number of times a given entry appears in bag. More...
 
virtual bool contains (const ItemType &anEntry) const =0
 Tests whether this bag contains a given entry. More...
 
virtual vector< ItemType > toVector () const =0
 Empties and then f ills a given vector with all entries that are in this bag. More...
 

Member Function Documentation

◆ add()

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 VectorBag< ItemType >.

◆ clear()

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 VectorBag< ItemType >.

◆ contains()

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 VectorBag< ItemType >.

◆ getCurrentSize()

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 VectorBag< ItemType >.

◆ getFrequencyOf()

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

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

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

Implemented in VectorBag< ItemType >.

◆ isEmpty()

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 VectorBag< ItemType >.

◆ remove()

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 VectorBag< ItemType >.

◆ toVector()

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

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

Returns
A vector containing all the entries in the bag.

Implemented in VectorBag< ItemType >.


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