#pragma once #include "data_structures/concurrent/skiplist.hpp" #include "utils/total_ordering.hpp" using std::pair; template class Item : public TotalOrdering>, public TotalOrdering>, public TotalOrdering, K>, public pair { public: using pair::pair; friend constexpr bool operator<(const Item &lhs, const Item &rhs) { return lhs.first < rhs.first; } friend constexpr bool operator==(const Item &lhs, const Item &rhs) { return lhs.first == rhs.first; } friend constexpr bool operator<(const K &lhs, const Item &rhs) { return lhs < rhs.first; } friend constexpr bool operator==(const K &lhs, const Item &rhs) { return lhs == rhs.first; } friend constexpr bool operator<(const Item &lhs, const K &rhs) { return lhs.first < rhs; } friend constexpr bool operator==(const Item &lhs, const K &rhs) { return lhs.first == rhs; } }; template class AccessorBase { typedef SkipList list; typedef typename SkipList::Iterator list_it; typedef typename SkipList::ConstIterator list_it_con; protected: AccessorBase(list *skiplist) : accessor(skiplist->access()) {} public: AccessorBase(const AccessorBase &) = delete; AccessorBase(AccessorBase &&other) : accessor(std::move(other.accessor)) {} ~AccessorBase() {} size_t size() { return accessor.size(); }; list_it begin() { return accessor.begin(); } list_it_con begin() const { return accessor.cbegin(); } list_it_con cbegin() const { return accessor.cbegin(); } list_it end() { return accessor.end(); } list_it_con end() const { return accessor.cend(); } list_it_con cend() const { return accessor.cend(); } template typename SkipList::template MultiIterator end(const K &data) { return accessor.template mend(data); } template typename SkipList::template MultiIterator mend(const K &data) { return accessor.template mend(data); } size_t size() const { return accessor.size(); } protected: typename list::Accessor accessor; };