7#ifndef GRAPHDOM_ADJ_LIST_BASE_ITERATOR_IMPL_H
8#define GRAPHDOM_ADJ_LIST_BASE_ITERATOR_IMPL_H
13#include "../adj_list_base_iterator.h"
15template<
typename VertexType>
16template<
typename VertexContainerPo
interType>
17graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::adj_list_base_iterator() :
18iterator_owner_graph(nullptr),
19iterator_owner_graph_edges_type(mixed),
20edge_begin_point_vertex_container(nullptr),
21edges_type_restriction(none),
23inner_iterator( special_begin_end_indicator() )
26template<
typename VertexType>
27template<
typename VertexContainerPo
interType>
28graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::adj_list_base_iterator(
31 const VertexContainerPointerType edge_begin_point_vertex_container,
34iterator_owner_graph(iterator_owner_pointer),
35iterator_owner_graph_edges_type(iterator_owner_graph_edges_type),
36edge_begin_point_vertex_container(edge_begin_point_vertex_container),
37edges_type_restriction(edges_type_restriction),
38inner_iterator_edge_current_type(inner_iterator_edge_current_type),
39inner_iterator( special_begin_end_indicator() ){}
41template<
typename VertexType>
42template<
typename VertexContainerPo
interType>
43graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::adj_list_base_iterator(
45 const typename graph<VertexType>::graph_edges_type iterator_owner_graph_edges_type,
46 const VertexContainerPointerType edge_begin_point_vertex_container,
47 const typename graph<VertexType>::edges_type_selection_type edges_type_restriction,
49 const typename graph<VertexType>::adj_set<graphdom::graph<VertexType>::vertex_container*>::iterator& inner_iterator) :
50iterator_owner_graph(iterator_owner_pointer),
51iterator_owner_graph_edges_type(iterator_owner_graph_edges_type),
52edge_begin_point_vertex_container(edge_begin_point_vertex_container),
53edges_type_restriction(edges_type_restriction),
54inner_iterator_edge_current_type(inner_iterator_edge_current_type),
55inner_iterator( inner_iterator ){}
57template<
typename VertexType>
58template<
typename VertexContainerPo
interType>
59graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::adj_list_base_iterator(
61 const typename graph<VertexType>::graph_edges_type iterator_owner_graph_edges_type,
62 const VertexContainerPointerType edge_begin_point_vertex_container,
63 const typename graph<VertexType>::edges_type_selection_type edges_type_restriction,
65 const typename graph<VertexType>::adj_set<
const graphdom::graph<VertexType>::vertex_container*>::iterator& inner_iterator) :
66iterator_owner_graph(iterator_owner_pointer),
67iterator_owner_graph_edges_type(iterator_owner_graph_edges_type),
68edge_begin_point_vertex_container(edge_begin_point_vertex_container),
69edges_type_restriction(edges_type_restriction),
70inner_iterator_edge_current_type(inner_iterator_edge_current_type),
71inner_iterator( inner_iterator ){}
73template<
typename VertexType>
74template<
typename VertexContainerPo
interType>
76constexpr bool graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::operator==(
77 const adj_list_base_iterator<K>& other_iterator)
const {
78 if ( inner_iterator_edge_current_type != other_iterator.inner_iterator_edge_current_type ) {
81 if ( std::holds_alternative< special_begin_end_indicator >( inner_iterator ) ) {
82 if ( std::holds_alternative< special_begin_end_indicator >( other_iterator.inner_iterator ) ) {
87 else if ( std::holds_alternative<
typename graph<VertexType>::adj_set<graph<VertexType>::vertex_container*>::iterator >( inner_iterator ) ) {
88 if ( ! std::holds_alternative<
typename graph<VertexType>::adj_set<graph<VertexType>::vertex_container*>::iterator >( other_iterator.inner_iterator ) ) {
91 return std::get< typename graph<VertexType>::adj_set<graph<VertexType>::vertex_container*>::iterator >( inner_iterator ) ==
92 std::get<
typename graph<VertexType>::adj_set<graph<VertexType>::vertex_container*>::iterator >( other_iterator.inner_iterator );
95 if ( ! std::holds_alternative<
typename graph<VertexType>::adj_set<
const graph<VertexType>::vertex_container*>::iterator >( other_iterator.inner_iterator ) ) {
98 return std::get< typename graph<VertexType>::adj_set<
const graph<VertexType>::vertex_container*>::iterator >( inner_iterator ) ==
99 std::get<
typename graph<VertexType>::adj_set<
const graph<VertexType>::vertex_container*>::iterator >( other_iterator.inner_iterator );
103template<
typename VertexType>
104template<
typename VertexContainerPo
interType>
106constexpr bool graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::operator!=(
107 const adj_list_base_iterator<K>& other_iterator)
const {
108 return !( (*this) == other_iterator );
111template<
typename VertexType>
112template<
typename VertexContainerPo
interType>
113constexpr graphdom::edge_type graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::edge_type()
const {
114 return inner_iterator_edge_current_type;
117template<
typename VertexType>
118template<
typename VertexContainerPo
interType>
120graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::internal_single_increment() {
122 return specialized_internal_single_increment< graphdom::graph<VertexType>::vertex_container* >();
125 return specialized_internal_single_increment< const graphdom::graph<VertexType>::vertex_container* >();
127 throw std::runtime_error(
"adj_list overflow");
130template<
typename VertexType>
131template<
typename VertexContainerPo
interType>
134graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::specialized_internal_single_increment() {
136 std::is_same< K , graphdom::graph<VertexType>::vertex_container* >::value ||
137 std::is_same< K , const graphdom::graph<VertexType>::vertex_container* >::value
139 "The typename 'K' of 'graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::specialized_internal_next<K>()' method must be a pointer to graphdom::graph<VertexType>::vertex_container"
141 auto& specialized_inner_iterator = std::get< typename graphdom::graph<VertexType>::adj_set<K>::iterator >( inner_iterator );
145 if ( adj_set_directed !=
nullptr ) {
146 if ( ! adj_set_directed->empty() ) {
147 inner_iterator = adj_set_directed->begin();
153 ++specialized_inner_iterator;
156 ++specialized_inner_iterator;
160template<
typename VertexType>
161template<
typename VertexContainerPo
interType>
164graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::get_adj_set_if_accessible(
const graphdom::edge_type edge_type)
const {
166 std::is_same< K , graphdom::graph<VertexType>::vertex_container* >::value ||
167 std::is_same< K , const graphdom::graph<VertexType>::vertex_container* >::value
169 "The typename 'K' of 'graphdom::graph<VertexType>::adj_list_base_iterator<VertexContainerPointerType>::get_adj_list<K>(graphdom::edge_type edge_type)' method must be a pointer to graphdom::graph<VertexType>::vertex_container"
171 auto*
const undirected_adj =
172 ( iterator_owner_graph_edges_type == mixed ) ?
173 &( (
static_cast< const typename graphdom::graph<VertexType>::mixed_graph_vertex_container<K
>* >( edge_begin_point_vertex_container ) )->undirected_adj )
176 ( iterator_owner_graph_edges_type ==
undirected ) ?
177 &( (
static_cast< const typename graphdom::graph<VertexType>::non_mixed_graph_vertex_container<K
>* >( edge_begin_point_vertex_container ) )->adj )
181 auto*
const directed_adj =
182 ( iterator_owner_graph_edges_type == mixed ) ?
183 &( (
static_cast< const typename graphdom::graph<VertexType>::mixed_graph_vertex_container<K
>* >( edge_begin_point_vertex_container ) )->directed_adj )
186 ( iterator_owner_graph_edges_type ==
directed ) ?
187 &( (
static_cast< const typename graphdom::graph<VertexType>::non_mixed_graph_vertex_container<K
>* >( edge_begin_point_vertex_container ) )->adj )
191 if ( edge_type == edge_type::undirected ) {
192 if ( edges_type_restriction != directed_edges ) {
193 return undirected_adj;
197 if ( edges_type_restriction != undirected_edges ) {
Every graph created using this library is an instance of a concrete class publicly derived,...
Definition graph.h:43
edge_type
The enumerated type whose values represent the two types of edges of a graph.
Definition graph.h:21
@ undirected
This enum value means undirected edge.
Definition graph.h:22
@ directed
This enum value means directed edge.
Definition graph.h:23