13 #ifndef __STOUT_HASHSET_HPP__ 14 #define __STOUT_HASHSET_HPP__ 17 #include <unordered_set> 20 #include <boost/get_pointer.hpp> 38 "Expecting enum type to be convertible to std::size_t");
39 return static_cast<std::size_t
>(t);
47 template <
typename Elem,
48 typename Hash =
typename std::conditional<
49 std::is_enum<Elem>::value,
52 typename Equal = std::equal_to<Elem>>
53 class hashset :
public std::unordered_set<Elem, Hash, Equal>
68 std::unordered_set<Elem, Hash, Equal>::reserve(
set.
size());
70 for (
auto iterator =
set.begin(); iterator !=
set.end(); ++iterator) {
71 std::unordered_set<Elem, Hash, Equal>::emplace(*iterator);
84 std::unordered_set<Elem, Hash, Equal>::reserve(
set.
size());
86 for (
auto iterator =
set.begin(); iterator !=
set.end(); ++iterator) {
87 std::unordered_set<Elem, Hash, Equal>::emplace(std::move(*iterator));
94 std::unordered_set<Elem, Hash, Equal>::reserve(list.size());
96 for (
auto iterator = list.begin(); iterator != list.end(); ++iterator) {
97 std::unordered_set<Elem, Hash, Equal>::emplace(*iterator);
104 return std::unordered_set<Elem, Hash, Equal>::count(elem) > 0;
109 template <
typename R,
typename T>
112 foreach (
const Elem& elem, *
this) {
113 const T* t = boost::get_pointer(elem);
114 if (t->*method() == r) {
122 template <
typename R,
typename T>
125 foreach (
const Elem& elem, *
this) {
126 const T* t = boost::get_pointer(elem);
127 if (t->*member == r) {
136 template <
typename Elem,
typename Hash,
typename Equal>
142 template <
typename Elem,
typename Hash,
typename Equal>
156 template <
typename Elem,
typename Hash,
typename Equal>
161 left.insert(right.begin(), right.end());
167 template <
typename Elem,
typename Hash,
typename Equal>
179 template <
typename Elem,
typename Hash,
typename Equal>
184 foreach (
const Elem& elem, right) {
191 #endif // __STOUT_HASHSET_HPP__ Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:130
bool exists(R(T::*method)(), R r) const
Definition: hashset.hpp:110
Definition: hashset.hpp:53
hashset< Elem, Hash, Equal > & operator|=(hashset< Elem, Hash, Equal > &left, const hashset< Elem, Hash, Equal > &right)
Definition: hashset.hpp:157
hashset(std::set< Elem > &&set)
Definition: hashset.hpp:79
hashset< Elem, Hash, Equal > & operator-=(hashset< Elem, Hash, Equal > &left, const hashset< Elem, Hash, Equal > &right)
Definition: hashset.hpp:180
hashset(const std::set< Elem > &set)
Definition: hashset.hpp:66
std::size_t operator()(T t) const
Definition: hashset.hpp:34
bool contains(const Elem &elem) const
Definition: hashset.hpp:102
bool exists(R(T::*member), R r) const
Definition: hashset.hpp:123
hashset< Elem, Hash, Equal > operator-(const hashset< Elem, Hash, Equal > &left, const hashset< Elem, Hash, Equal > &right)
Definition: hashset.hpp:168
hashset()
Definition: hashset.hpp:60
hashset< Elem, Hash, Equal > operator|(const hashset< Elem, Hash, Equal > &left, const hashset< Elem, Hash, Equal > &right)
Definition: hashset.hpp:143
hashset(std::initializer_list< Elem > list)
Definition: hashset.hpp:92
static const hashset< Elem, Hash, Equal > & EMPTY
Definition: hashset.hpp:56
Try< std::vector< Entry > > list(const std::string &hierarchy, const std::string &cgroup)
Try< uint32_t > type(const std::string &path)
Definition: hashset.hpp:31