Visual Computing Library
Loading...
Searching...
No Matches
adjacent_node_iterator.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_SPACE_COMPLEX_GRAPH_BIPARTITE_ITERATORS_ADJACENT_NODE_ITERATOR_H
24#define VCL_SPACE_COMPLEX_GRAPH_BIPARTITE_ITERATORS_ADJACENT_NODE_ITERATOR_H
25
26namespace vcl::detail {
27
28template<typename Graph, typename Iterator>
29class AdjacentNodeIterator
30{
31protected:
32 const Graph* mGraph = nullptr;
33 Iterator mIt;
34
35public:
36 AdjacentNodeIterator() {}
37
38 AdjacentNodeIterator(const Graph& g, Iterator it) : mGraph(&g), mIt(it) {}
39
40 bool operator==(const AdjacentNodeIterator& otherIterator) const
41 {
42 return (mGraph == otherIterator.mGraph && mIt == otherIterator.mIt);
43 }
44
45 bool operator!=(const AdjacentNodeIterator& otherIterator) const
46 {
47 return !(*this == otherIterator);
48 }
49
50 AdjacentNodeIterator operator++()
51 {
52 ++mIt;
53 return *this;
54 }
55
56 AdjacentNodeIterator operator++(int)
57 {
58 AdjacentNodeIterator tmp;
59 ++mIt;
60 return tmp;
61 }
62};
63
64} // namespace vcl::detail
65
66#endif // VCL_SPACE_COMPLEX_GRAPH_BIPARTITE_ITERATORS_ADJACENT_NODE_ITERATOR_H