Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
CapacityEdge.hpp
Go to the documentation of this file.
1
6// Copyright (c) 2017 Czech Technical University in Prague | Faculty of Information Technology. All rights reserved.
7
8#pragma once
9
10#include <ostream>
11#include <alib/pair>
12#include <object/Object.h>
13#include <alib/tuple>
14
15#include <edge/EdgeFeatures.hpp>
16#include <edge/EdgeBase.hpp>
17
18namespace edge {
19
20template<typename TNode, typename TCapacity>
21class CapacityEdge : public ext::pair<TNode, TNode>, public EdgeBase {
22// ---------------------------------------------------------------------------------------------------------------------
23 public:
24 using node_type = TNode;
25 using capacity_type = TCapacity;
27
28// ---------------------------------------------------------------------------------------------------------------------
29
30 protected:
31 TCapacity m_capacity;
32
33// =====================================================================================================================
34// Constructor, Destructor, Operators
35
36 public:
37 explicit CapacityEdge(TNode _first, TNode _second, TCapacity capacity);
38
39// ---------------------------------------------------------------------------------------------------------------------
40
41 TCapacity capacity() const;
42 void capacity(TCapacity &&capacity);
43
44// =====================================================================================================================
45// EdgeBase interface
46
47 public:
48 auto operator <=> (const CapacityEdge &other) const {
49 return ext::tie(this->first, this->second, m_capacity) <=> ext::tie(other.first, other.second, other.m_capacity);
50 }
51
52 bool operator == (const CapacityEdge &other) const {
53 return ext::tie(this->first, this->second, m_capacity) == ext::tie(other.first, other.second, other.m_capacity);
54 }
55
56 void operator>>(ext::ostream &ostream) const override;
57
58// =====================================================================================================================
59 public:
60
61 virtual std::string name() const;
62
63// ---------------------------------------------------------------------------------------------------------------------
64};
65// =====================================================================================================================
66
67template<typename TNode, typename TCapacity>
68CapacityEdge<TNode, TCapacity>::CapacityEdge(TNode _first, TNode _second, TCapacity capacity)
69 : ext::pair<TNode, TNode>(_first, _second), m_capacity(capacity) {
70
71}
72
73// ---------------------------------------------------------------------------------------------------------------------
74
75template<typename TNode, typename TCapacity>
77 return m_capacity;
78}
79
80template<typename TNode, typename TCapacity>
81void CapacityEdge<TNode, TCapacity>::capacity(TCapacity &&capacity) {
82 m_capacity = std::forward<TCapacity>(capacity);
83}
84
85// ---------------------------------------------------------------------------------------------------------------------
86
87template<typename TNode, typename TCapacity>
89 return "CapacityEdge";
90}
91
92// ---------------------------------------------------------------------------------------------------------------------
93
94template<typename TNode, typename TCapacity>
96 ostream << "(" << name() << "(first=" << this->first << ", second=" << this->second << ", weight="
97 << m_capacity << "))";
98}
99
100// ---------------------------------------------------------------------------------------------------------------------
101
102} // namespace edge
103
104// =====================================================================================================================
105
106
Definition: CapacityEdge.hpp:21
bool operator==(const CapacityEdge &other) const
Definition: CapacityEdge.hpp:52
auto operator<=>(const CapacityEdge &other) const
Definition: CapacityEdge.hpp:48
TCapacity capacity() const
Definition: CapacityEdge.hpp:76
CapacityEdge(TNode _first, TNode _second, TCapacity capacity)
Definition: CapacityEdge.hpp:68
TCapacity capacity_type
Definition: CapacityEdge.hpp:25
virtual std::string name() const
Definition: CapacityEdge.hpp:88
TNode node_type
Definition: CapacityEdge.hpp:24
TCapacity m_capacity
Definition: CapacityEdge.hpp:31
void operator>>(ext::ostream &ostream) const override
Definition: CapacityEdge.hpp:95
Definition: EdgeBase.hpp:15
Definition: WeightedEdge.hpp:21
Definition: ostream.h:14
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
p second
Definition: ToRegExpAlgebraic.h:126
Definition: CapacityEdge.hpp:18
Definition: sigHandler.cpp:20
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218