memgraph/include/data_structures/concurrent/concurrent_set.hpp
Kruno Tomola Fabro 8a89f6601d EdgeType indexes added.
Implemented untested UniqueOrderedIndex.

Introduced TypeGroupEdge/Vertex into database.

Added Index capabilityes to PropertyFamily.
Added method for adding index.
Added method for removing index.
2016-08-25 15:29:45 +01:00

73 lines
1.7 KiB
C++

#pragma once
#include "data_structures/concurrent/common.hpp"
#include "data_structures/concurrent/skiplist.hpp"
template <class T>
class ConcurrentSet
{
typedef SkipList<T> list;
typedef typename SkipList<T>::Iterator list_it;
typedef typename SkipList<T>::ConstIterator list_it_con;
public:
ConcurrentSet() {}
class Accessor : public AccessorBase<T>
{
friend class ConcurrentSet;
using AccessorBase<T>::AccessorBase;
private:
using AccessorBase<T>::accessor;
public:
std::pair<list_it, bool> insert(const T &item)
{
return accessor.insert(item);
}
std::pair<list_it, bool> insert(T &&item)
{
return accessor.insert(std::move(item));
}
list_it_con find(const T &item) const { return accessor.find(item); }
list_it find(const T &item) { return accessor.find(item); }
template <class K>
list_it_con find_or_larger(const K &item) const
{
return accessor.find_or_larger(item);
}
template <class K>
list_it find_or_larger(const K &item)
{
return accessor.find_or_larger(item);
}
template <class K>
list_it_con cfind_or_larger(const K &item)
{
return accessor.template find_or_larger<list_it_con, K>(item);
}
bool contains(const T &item) const
{
return this->find(item) != this->end();
}
bool remove(const T &item) { return accessor.remove(item); }
};
Accessor access() { return Accessor(&skiplist); }
const Accessor access() const { return Accessor(&skiplist); }
private:
list skiplist;
};