5a42e15c4a
Squashed messages from 9 commits: 9. Properties now uses PropertyFamily and contained classes. Fetching,seting,clearing properties can be done with PropertyFamilyKey or PropertyTypeKey. Hierarchy of newly added clases is: Vertices -n-> PropertyFamily {name: String} <-1-n-> PropertyType {type: Property::Flags} Edges -n-> PropertyFamily {name: String} <-1-n-> PropertyType {type: Property::Flags} PropertyFamilyKey -> PropertyType PropertyTypeKey -> PropertyType PropertyType t0,t1; let t0!=t1 be true let t0.family==t1.family be true then next is true PropertyTypeKey{&t0}!=PropertyTypeKey{&t1} PropertyFamilyKey{&t0}==PropertyFamilyKey{&t1} PropertyFamilyKey{&t0}==PropertyTypeKey{&t1} PropertyTypeKey{&t0}==PropertyFamilyKey{&t1} 8. Intermedate commit. Noticed that integration queries throw SEGFAULT. 7. Defined interface for indexes. Fixed three memory leaks. Fixed integration_queries test which now passes. 6. Commit which return Xorshift128plus to valid shape. 5. Tmp commit. 4. Label Index is compiling. 3. tmp 2. Vertex::Accessor now updates Label index. 1. Applied changes for code review.
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "utils/iterator/iterator_base.hpp"
|
|
#include "utils/option.hpp"
|
|
|
|
namespace iter
|
|
{
|
|
|
|
// Class which turns accessor int next() based iterator.
|
|
// T - type of return value
|
|
// I - iterator type gotten from accessor
|
|
// A - accessor type
|
|
template <class T, class I, class A>
|
|
class IteratorAccessor : public IteratorBase<T>
|
|
{
|
|
public:
|
|
IteratorAccessor() = delete;
|
|
|
|
IteratorAccessor(A &&acc)
|
|
: begin(std::move(acc.begin())), acc(std::forward<A>(acc))
|
|
{
|
|
}
|
|
// Iter(const Iter &other) = delete;
|
|
// Iter(Iter &&other) :
|
|
// begin(std::move(other.begin)),end(std::move(other.end)) {};
|
|
|
|
Option<T> next() final
|
|
{
|
|
if (begin != acc.end()) {
|
|
auto ret = Option<T>(&(*(begin.operator->())));
|
|
begin++;
|
|
return ret;
|
|
} else {
|
|
return Option<T>();
|
|
}
|
|
}
|
|
|
|
private:
|
|
I begin;
|
|
A acc;
|
|
};
|
|
|
|
// TODO: Join to make functions into one
|
|
template <class A>
|
|
auto make_iter(A &&acc)
|
|
{
|
|
// Compiler cant deduce types T and I. decltype are here to help with it.
|
|
return IteratorAccessor<decltype(&(*(acc.begin().operator->()))),
|
|
decltype(acc.begin()), A>(std::move(acc));
|
|
}
|
|
|
|
template <class A>
|
|
auto make_iter_ref(A &acc)
|
|
{
|
|
// Compiler cant deduce types T and I. decltype are here to help with it.
|
|
return IteratorAccessor<decltype(&(*(acc.begin().operator->()))),
|
|
decltype(acc.begin()), A &>(acc);
|
|
}
|
|
}
|