Skip to content

Commit

Permalink
update unorderedset
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Mar 6, 2024
1 parent c771f78 commit cc2f444
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/flatmemory/details/containers/unordered_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ namespace flatmemory {

template<typename T>
struct CustomHash {
size_t operator()(const T& element) const {
size_t operator()(const ConstView<T>& element) const {
return element.hash();
}
};

template<typename T>
struct CustomEqual {
bool operator()(const T& left_element, const T& right_element) const {
bool operator()(const ConstView<T>& left_element, const ConstView<T>& right_element) const {
return left_element == right_element;
}
};
Expand All @@ -34,18 +34,18 @@ struct CustomEqual {
* but without the functionality to erase elements
* since m_storage would keep growing.
*/
template<typename T>
template<typename T, typename Hash = CustomHash<T>, typename Equal = CustomEqual<T>>
class UnorderedSet
{
private:
// Persistent storage
ByteBufferSegmented m_storage;

// Data to be accessed
std::unordered_set<ConstView<T>, CustomHash<ConstView<T>>, CustomEqual<ConstView<T>>> m_data;
std::unordered_set<ConstView<T>, Hash, Equal> m_data;

using iterator = std::unordered_set<ConstView<T>>::iterator;
using const_iterator = std::unordered_set<ConstView<T>>::const_iterator;
using iterator = std::unordered_set<ConstView<T>, Hash, Equal>::iterator;
using const_iterator = std::unordered_set<ConstView<T>, Hash, Equal>::const_iterator;

public:
explicit UnorderedSet(NumBytes n = 1000000)
Expand Down

0 comments on commit cc2f444

Please sign in to comment.