◆ Bag()
template<class ItemType >
◆ ~Bag()
template<class ItemType >
◆ add()
template<class ItemType>
bool Bag< ItemType >::add |
( |
const ItemType & |
newEntry | ) |
|
Adds a new item to the bag.
- Postcondition
- If successful, newEntry is added to the bag, and the number of items in the bag has increased by 1.
- Parameters
-
newItem | The item (of datatype ItemType) to be added. |
- Returns
- True if insert was successful, or false if not.
◆ clear()
template<class ItemType >
void Bag< ItemType >::clear |
( |
| ) |
|
Deletes all entries from this bag.
- Postcondition
- The bag contains no items, and the number of items is 0.
◆ contains()
template<class ItemType>
bool Bag< ItemType >::contains |
( |
const ItemType & |
anEntry | ) |
const |
Tests whether this bag contains a given item.
- Parameters
-
anItem | The item to locate. |
- Returns
- True if bag contains anEntry, or false otherwise.
◆ getFrequencyOf()
template<class ItemType>
int Bag< ItemType >::getFrequencyOf |
( |
const ItemType & |
anEntry | ) |
const |
Returns the number of times a given item appears in this bag.
- Parameters
-
anItem | The item to locate. |
- Returns
- The integer number of times the item is in this bag.
◆ isEmpty()
template<class ItemType >
bool Bag< ItemType >::isEmpty |
( |
| ) |
const |
Determines whether this bag is empty.
- Returns
- True if the bag has no items, or false if not.
◆ size()
template<class ItemType >
int Bag< ItemType >::size |
( |
| ) |
const |
Returns the number of items in the bag.
- Returns
- The integer number of items in bag.
◆ toVector()
template<class ItemType >
std::vector< ItemType > Bag< ItemType >::toVector |
( |
| ) |
const |
Empties and then fills a given vector with all items that are in this bag.
- Returns
- A vector containing all the items in the bag.
The documentation for this class was generated from the following files: