Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4003CEM-datastructs/set.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (40 sloc)
1.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SET_H | |
#define SET_H | |
#include <exception> | |
#include <memory> | |
class Set | |
{ | |
private: | |
const int maxSize; | |
std::unique_ptr<char[]> set; | |
public: | |
class Full: public std::exception | |
{ | |
public: | |
virtual const char* what() const throw(); | |
}; | |
class Empty: public std::exception | |
{ | |
public: | |
virtual const char* what() const throw(); | |
}; | |
/** Initialise the queue, maxSize is the maximum number of | |
values that can be stored in the queue at any time **/ | |
Set( const int _maxSize ); | |
~Set(); | |
/** Returns the number of values currently stored in the | |
queue **/ | |
int num_items() const; | |
/** Add value to the set, return true if the value was added | |
* returns false if the value was already in the set. | |
* raises Set::Full if value was not in set but no space to | |
* add it. **/ | |
bool add( char value ); | |
/** Returns true if the value is in the set, false if not in | |
* the set **/ | |
bool is_in( char value ) const; | |
/** Removes the value from the set. returns false if value | |
* was not in the set **/ | |
bool remove( char value ); | |
}; | |
#endif |