#pragma once #include "data_structures/concurrent/skiplist.hpp" #include "utils/total_ordering.hpp" using std::pair; template class ConcurrentMultiMap { typedef Item item_t; typedef SkipList list; typedef typename SkipList::Iterator list_it; typedef typename SkipList::ConstIterator list_it_con; typedef typename SkipList::template MultiIterator list_it_multi; public: ConcurrentMultiMap() {} class Accessor : public AccessorBase { friend class ConcurrentMultiMap; using AccessorBase::AccessorBase; private: using AccessorBase::accessor; public: list_it insert(const K &key, const T &data) { return accessor.insert_non_unique(item_t(key, data)); } list_it insert(const K &key, T &&data) { return accessor.insert_non_unique( item_t(key, std::forward(data))); } list_it insert(K &&key, T &&data) { return accessor.insert_non_unique( item_t(std::forward(key), std::forward(data))); } list_it_multi find_multi(const K &key) { return accessor.find_multi(key); } list_it_con find(const K &key) const { return accessor.find(key); } list_it find(const K &key) { return accessor.find(key); } bool contains(const K &key) const { return this->find(key) != this->end(); } bool remove(const K &key) { return accessor.remove(key); } }; Accessor access() { return Accessor(&skiplist); } const Accessor access() const { return Accessor(&skiplist); } private: list skiplist; };