GraphDom
Loading...
Searching...
No Matches
multiset_graph_adj_list_iterator.h
1/*
2 * Copyright 2026 Michele Comparini
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef GRAPHDOM_MULTISET_GRAPH_ADJ_LIST_ITERATOR_IMPL_H
8#define GRAPHDOM_MULTISET_GRAPH_ADJ_LIST_ITERATOR_IMPL_H
9
10#include "../../graph.h"
11#include "../adj_list_base_iterator.h"
12#include "../adj_list_iterator.h"
13#include "../../multiset_graph.h"
14#include "../multiset_graph_adj_list_iterator.h"
15
16template<typename VertexType>
17graphdom::multiset_graph<VertexType>::adj_list_iterator::adj_list_iterator(const adj_list_iterator& other) :
18graphdom::graph<VertexType>::template adj_list_base_iterator< typename graph<VertexType>::vertex_container* >( other ){}
19
20template<typename VertexType>
21graphdom::multiset_graph<VertexType>::adj_list_iterator::adj_list_iterator(const typename graph<VertexType>::adj_list_iterator& other) :
22graphdom::graph<VertexType>::template adj_list_base_iterator< typename graph<VertexType>::vertex_container* >(
23 other.iterator_owner_graph,
24 other.iterator_owner_graph_edges_type,
25 static_cast< typename graph<VertexType>::vertex_container* >( nullptr ),
26 other.edges_type_restriction,
27 other.inner_iterator_edge_current_type
28) {
29 if ( dynamic_cast< const graphdom::multiset_graph<VertexType>* >( this->iterator_owner_graph ) == nullptr ) {
30 throw std::runtime_error("Convertion error"); //TODO: write a better message
31 }
32 this->edge_begin_point_vertex_container = const_cast< typename graph<VertexType>::vertex_container* >( other.edge_begin_point_vertex_container );
33 this->inner_iterator = other.inner_iterator;
34}
35
36template<typename VertexType>
37typename graphdom::multiset_graph<VertexType>::vertex_handle graphdom::multiset_graph<VertexType>::adj_list_iterator::operator->() const {
38 return *this;
39}
40
41template<typename VertexType>
42typename graphdom::multiset_graph<VertexType>::vertex_handle graphdom::multiset_graph<VertexType>::adj_list_iterator::operator*() const {
43 return graphdom::multiset_graph<VertexType>::vertex_handle(
44 this->iterator_owner_graph,
45 this->iterator_owner_graph_edges_type,
46 ( *( std::get< typename graphdom::graph<VertexType>::template adj_set<typename graphdom::graph<VertexType>::vertex_container*>::iterator >( this->inner_iterator ) ) )->vertex_container_ptr
47 );
48}
49
50template<typename VertexType>
51typename graphdom::multiset_graph<VertexType>::adj_list_iterator& graphdom::multiset_graph<VertexType>::adj_list_iterator::operator=(const adj_list_iterator& other) {
52 if ( this != &other ) {
53 this->iterator_owner_graph = other.iterator_owner_graph;
54 this->iterator_owner_graph_edges_type = other.iterator_owner_graph_edges_type;
55 this->edge_begin_point_vertex_container = other.edge_begin_point_vertex_container;
56 this->edges_type_restriction = other.edges_type_restriction;
57 this->inner_iterator_edge_current_type = other.inner_iterator_edge_current_type;
58 this->inner_iterator = other.inner_iterator;
59 }
60 return *this;
61}
62
63template<typename VertexType>
64typename graphdom::multiset_graph<VertexType>::adj_list_iterator& graphdom::multiset_graph<VertexType>::adj_list_iterator::operator++() {
65 this->internal_single_increment();
66 return *this;
67}
68
69template<typename VertexType>
70typename graphdom::multiset_graph<VertexType>::adj_list_iterator graphdom::multiset_graph<VertexType>::adj_list_iterator::operator++(int) {
71 auto to_return = *this;
72 ++(*this);
73 return to_return;
74}
75
76template<typename VertexType>
77graphdom::multiset_graph<VertexType>::adj_list_iterator::adj_list_iterator(const typename graph<VertexType>::template adj_list_base_iterator<typename graph<VertexType>::vertex_container*>& other) :
78graphdom::graph<VertexType>::template adj_list_base_iterator< typename graph<VertexType>::vertex_container* >( other ){}
79
80template<typename VertexType>
81graphdom::multiset_graph<VertexType>::adj_list_iterator::adj_list_iterator(
82 const graph<VertexType>* const iterator_owner_pointer,
83 const typename graph<VertexType>::graph_edges_type iterator_owner_graph_edges_type,
84 typename graph<VertexType>::vertex_container* const edge_begin_point_vertex_container,
85 const typename graph<VertexType>::edges_type_selection_type edges_type_restriction,
86 const graphdom::edge_type inner_iterator_edge_current_type) :
87graphdom::graph<VertexType>::template adj_list_base_iterator< typename graph<VertexType>::vertex_container* >(
88 iterator_owner_pointer,
89 iterator_owner_graph_edges_type,
90 edge_begin_point_vertex_container,
91 edges_type_restriction,
92 inner_iterator_edge_current_type
93) {}
94
95template<typename VertexType>
96graphdom::multiset_graph<VertexType>::adj_list_iterator::adj_list_iterator(
97 const graph<VertexType> *iterator_owner_pointer,
98 const typename graph<VertexType>::graph_edges_type iterator_owner_graph_edges_type,
99 typename graph<VertexType>::vertex_container* const edge_begin_point_vertex_container,
100 const typename graph<VertexType>::edges_type_selection_type edges_type_restriction,
101 const graphdom::edge_type inner_iterator_edge_current_type,
102 const typename graph<VertexType>::template adj_set<typename graph<VertexType>::vertex_container* >::iterator& inner_iterator) :
103graphdom::graph<VertexType>::template adj_list_base_iterator< typename graph<VertexType>::vertex_container* >(
104 iterator_owner_pointer,
105 iterator_owner_graph_edges_type,
106 edge_begin_point_vertex_container,
107 edges_type_restriction,
108 inner_iterator_edge_current_type,
109 inner_iterator
110) {}
111
112#endif //GRAPHDOM_MULTISET_GRAPH_ADJ_LIST_ITERATOR_IMPL_H
Every valid instance of this class can be used to identify a specific vertex of a multiset graph and ...
Definition multiset_graph_vertex_handle.h:31
Every multiset graph created using this library is an instance of a concrete class publicly derived,...
Definition multiset_graph.h:19
Definition adj_list.h:16
edge_type
The enumerated type whose values represent the two types of edges of a graph.
Definition graph.h:21