Abstract Data Types
add(some_item): bool
- attempt to add some_item to the set. If it is already present, don’t duplicate it in the set. Returns true if item was successfully added or false if it is a duplicate.remove(some_item): bool
- remove some_item from the set if it is present. Returns true if the item was successfully removed and false otherwise.clear(): void
- remove all items from the setfind(some_item): bool
- returns true if some_item is found inside the set.Class Templates allow us to write code that will work for multiple data types.
//A DSSet contains a unique collection of items.
//Attempting to add an element that already exists in the set doesn't
//cause a duplicate to be created.
template <typename T>
class DSSet {
private:
T* items;
int cap;
int size;
public:
//...
};
//To instantiate a DSSet object:
DSSet<int> set_of_integers;
DSSet<float> set_of_floats;
//Assume we had a class Person already declared
class Person {...};
DSSet<Person> set_of_persons;
DSVector<T>
pushBack(…)
resize()
Adding multiple targets in the CMakeList.txt file to support Testing
add_executable(...)
generates a different executable file.add_executable(...)
will be the name of the executableExtra help with Catch: