Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
AdjacencyContainerDecorator.hpp
Go to the documentation of this file.
1#pragma once
2#include <algorithm>
4
6
7namespace fishnet::graph{
8
15template<class AdjDelegate>
17private:
18 using N = typename AdjDelegate::node_type;
19 static_assert(AdjacencyContainer<AdjDelegate,N>, "AdjDelegate must be an AdjacencyContainer");
20 AdjDelegate delegate;
21public:
22 using node_type = typename AdjDelegate::node_type;
23 using equality_predicate = typename AdjDelegate::equality_predicate;
24 using hash_function = typename AdjDelegate::hash_function;
25
26 AdjacencyContainerDecorator(const AdjDelegate & delegate): delegate(delegate) {}
27
28 AdjacencyContainerDecorator(AdjDelegate && delegate) : delegate(std::move(delegate)) {}
29
30 void addAdjacency(const N & from, const N & to) {
31 delegate.addAdjacency(from, to);
32 }
33
34 void addAdjacency(N && from, N && to) {
35 delegate.addAdjacency(std::move(from), std::move(to));
36 }
37
38 void addAdjacencies(util::forward_range_of<std::pair<N,N>> auto && pairs){
39 delegate.addAdjacencies(std::forward<decltype(pairs)>(pairs));
40 }
41
42 bool addNode(const N & node){
43 return delegate.addNode(node);
44 }
45
46 bool addNode(N && node){
47 return delegate.addNode(std::move(node));
48 }
49
51 return delegate.addNodes(std::forward<decltype(nodes)>(nodes));
52 }
53
54 void removeNode(const N & node){
55 delegate.removeNode(node);
56 }
57
59 delegate.removeNodes(std::forward<decltype(nodes)>(nodes));
60 }
61
62 void removeAdjacency(const N & from, const N & to){
63 delegate.removeAdjacency(from,to);
64 }
65
66 void removeAdjacencies(util::forward_range_of<std::pair<N,N>> auto && pairs){
67 delegate.removeAdjacencies(std::forward<decltype(pairs)>(pairs));
68 }
69
70 bool contains(const N & node) const noexcept {
71 return delegate.contains(node);
72 }
73
74 bool hasAdjacency(const N & from, const N & to) const noexcept {
75 return delegate.hasAdjacency(from,to);
76 }
77
78 auto adjacency(const N & node) const noexcept {
79 return delegate.adjacency(node);
80 }
81
82 auto nodes() const noexcept {
83 return delegate.nodes();
84 }
85
86 auto getAdjacencyPairs() const noexcept {
87 return delegate.getAdjacencyPairs();
88 }
89
90 void clear() noexcept{
91 delegate.clear();
92 }
93
94};
95}
A decorator for adjacency containers that adds additional functionality.
Definition AdjacencyContainerDecorator.hpp:16
typename AdjDelegate::equality_predicate equality_predicate
Definition AdjacencyContainerDecorator.hpp:23
bool addNode(N &&node)
Definition AdjacencyContainerDecorator.hpp:46
bool contains(const N &node) const noexcept
Definition AdjacencyContainerDecorator.hpp:70
void addAdjacency(N &&from, N &&to)
Definition AdjacencyContainerDecorator.hpp:34
auto getAdjacencyPairs() const noexcept
Definition AdjacencyContainerDecorator.hpp:86
auto nodes() const noexcept
Definition AdjacencyContainerDecorator.hpp:82
bool addNodes(util::forward_range_of< N > auto &&nodes)
Definition AdjacencyContainerDecorator.hpp:50
void removeAdjacency(const N &from, const N &to)
Definition AdjacencyContainerDecorator.hpp:62
typename AdjDelegate::node_type node_type
Definition AdjacencyContainerDecorator.hpp:22
auto adjacency(const N &node) const noexcept
Definition AdjacencyContainerDecorator.hpp:78
void addAdjacencies(util::forward_range_of< std::pair< N, N > > auto &&pairs)
Definition AdjacencyContainerDecorator.hpp:38
void addAdjacency(const N &from, const N &to)
Definition AdjacencyContainerDecorator.hpp:30
void removeAdjacencies(util::forward_range_of< std::pair< N, N > > auto &&pairs)
Definition AdjacencyContainerDecorator.hpp:66
bool addNode(const N &node)
Definition AdjacencyContainerDecorator.hpp:42
void removeNode(const N &node)
Definition AdjacencyContainerDecorator.hpp:54
AdjacencyContainerDecorator(AdjDelegate &&delegate)
Definition AdjacencyContainerDecorator.hpp:28
bool hasAdjacency(const N &from, const N &to) const noexcept
Definition AdjacencyContainerDecorator.hpp:74
void clear() noexcept
Definition AdjacencyContainerDecorator.hpp:90
AdjacencyContainerDecorator(const AdjDelegate &delegate)
Definition AdjacencyContainerDecorator.hpp:26
void removeNodes(util::forward_range_of< N > auto &&nodes)
Definition AdjacencyContainerDecorator.hpp:58
typename AdjDelegate::hash_function hash_function
Definition AdjacencyContainerDecorator.hpp:24
Interface for an AdjacencyContainer.
Definition AdjacencyContainer.hpp:12
Definition CollectionConcepts.hpp:27
Definition AdjacencyContainer.hpp:4
STL namespace.