#ifndef __ODS_ODS_SIMPSSET__ #define __ODS_ODS_SIMPSSET__ #include #include #include namespace ods { template class SimpSSet : public SSet { public: SimpSSet(void); ~SimpSSet(void); std::size_t size(void); bool add(T); std::optional remove(T); std::optional find(T); private: SimpList list; }; template SimpSSet::SimpSSet() { } template SimpSSet::~SimpSSet() { } template std::size_t SimpSSet::size() { return this->list.size(); } template bool SimpSSet::add(T value) { for (std::size_t i = 0; i < this->list.size(); i++) { if (this->list.get(i) == value) { return false; } } for (std::size_t i = 0; i < this->list.size(); i++) { if (this->list.get(i) < value) { continue; } this->list.add(i, value); return true; } this->list.add(this->list.size(), value); return true; } template std::optional SimpSSet::remove(T value) { for (std::size_t i = 0; i < this->list.size(); i++) { if (this->list.get(i) == value) { auto removed = this->list.get(i); this->list.remove(i); return removed; } } return std::nullopt; } template std::optional SimpSSet::find(T value) { for (std::size_t i = 0; i < this->list.size(); i++) { if (this->list.get(i) == value) { return this->list.get(i); } } return std::nullopt; } } // namespace ods #endif // __ODS_ODS_SIMPSSET__