#pragma once #include #include namespace BWAPI { template using SetContainerUnderlyingT = std::unordered_set < T, HashT >; /// This container is used to wrap convenience functions for BWAPI and be used as a /// bridge with a built-in set type. /// /// @tparam T /// Type that this set contains. /// @tparam HashT /// Hash type. Defaults to integral hashing for BWAPI usage. template > class SetContainer : public SetContainerUnderlyingT < T, HashT > { public: SetContainer() : SetContainerUnderlyingT() {} SetContainer(SetContainer const &other) : SetContainerUnderlyingT(other) {} SetContainer(SetContainer &&other) : SetContainerUnderlyingT(std::forward(other)) {} SetContainer(std::initializer_list ilist) : SetContainerUnderlyingT(ilist) {} template SetContainer(IterT _begin, IterT _end) : SetContainerUnderlyingT(_begin, _end) {} /// Iterates the set and erases each element x where pred(x) returns true. /// /// /// Predicate for removing elements. /// /// @see std::erase_if template void erase_if(const Pred& pred) { auto it = this->begin(); while (it != this->end()) { if (pred(*it)) it = this->erase(it); else ++it; } }; /// Checks if this set contains a specific value. /// /// /// Value to search for. /// bool contains(T const &value) const { return count(value) != 0; } }; }