24 template<
class ItemType>
30 bool add(
const ItemType& newEntry);
31 bool remove(
const ItemType& anEntry);
33 bool contains(
const ItemType& anEntry)
const;
59 vector<ItemType> items;
63 int getIndexOf(
const ItemType& target)
const;
bool contains(const ItemType &anEntry) const
Tests whether this bag contains a given entry.
Definition: VectorBag.cpp:71
VectorBag< ItemType > operator*(VectorBag< ItemType > anotherBag)
Creates a new bag that contains those objects that occur in both this bag and a second given bag with...
Definition: VectorBag.cpp:101
CISC 2200: Data Structures Project 2: Extending the Bag ADT
vector< ItemType > toVector() const
Empties and then f ills a given vector with all entries that are in this bag.
Definition: VectorBag.cpp:80
int getCurrentSize() const
Gets the current number of entries in this bag.
Definition: VectorBag.cpp:18
int getFrequencyOf(const ItemType &anEntry) const
Counts the number of times a given entry appears in bag.
Definition: VectorBag.cpp:59
VectorBag< ItemType > operator-(VectorBag< ItemType > anotherBag)
Creates a new bag of objects that would be left in this bag after removing those that also occur in a...
Definition: VectorBag.cpp:109
VectorBag< ItemType > operator+(VectorBag< ItemType > anotherBag)
Creates a new bag that combines the contents of this bag and a second given bag without affecting the...
Definition: VectorBag.cpp:87
bool add(const ItemType &newEntry)
Adds a new entry to this bag.
Definition: VectorBag.cpp:30
VectorBag is a vector-based implementation of BagInterface.
Definition: VectorBag.h:25
Definition: BagInterface.h:13
bool isEmpty() const
Sees whether this bag is empty.
Definition: VectorBag.cpp:24
void clear()
Removes all entries from this bag.
Definition: VectorBag.cpp:53