Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Edge.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 <sstream>
11#include <alib/pair>
12#include <alib/tuple>
13#include <object/Object.h>
14
15#include "EdgeBase.hpp"
16#include "EdgeFeatures.hpp"
17
18namespace edge {
19
20template<typename TNode>
21class Edge : public ext::pair<TNode, TNode>, public EdgeBase {
22// ---------------------------------------------------------------------------------------------------------------------
23 public:
24 using node_type = TNode;
26
27// ---------------------------------------------------------------------------------------------------------------------
28// =====================================================================================================================
29// Constructor, Destructor, Operators
30
31 public:
32 explicit Edge(TNode _first, TNode _second);
33
34// =====================================================================================================================
35// EdgeBase interface
36
37 public:
38 auto operator <=> (const Edge &other) const {
39 return ext::tie(this->first, this->second) <=> ext::tie(other.first, other.second);
40 }
41
42 bool operator == (const Edge &other) const {
43 return ext::tie(this->first, this->second) == ext::tie(other.first, other.second);
44 }
45
46 void operator>>(ext::ostream &ostream) const override;
47
48// =====================================================================================================================
49 public:
50
51 virtual std::string name() const;
52
53// ---------------------------------------------------------------------------------------------------------------------
54};
55// =====================================================================================================================
56
57template<typename TNode>
58Edge<TNode>::Edge(TNode _first, TNode _second)
59 : ext::pair<TNode, TNode>(_first, _second) {
60
61}
62
63// ---------------------------------------------------------------------------------------------------------------------
64
65template<typename TNode>
66std::string Edge<TNode>::name() const {
67 return "Edge";
68}
69
70// ---------------------------------------------------------------------------------------------------------------------
71
72template<typename TNode>
74 ostream << "(" << name() << "(first=" << this->first << ", second=" << this->second << "))";
75}
76
77// ---------------------------------------------------------------------------------------------------------------------
78
79} // namespace edge
80
81// =====================================================================================================================
82
Definition: EdgeBase.hpp:15
Definition: Edge.hpp:21
TNode node_type
Definition: Edge.hpp:24
Edge(TNode _first, TNode _second)
Definition: Edge.hpp:58
void operator>>(ext::ostream &ostream) const override
Definition: Edge.hpp:73
bool operator==(const Edge &other) const
Definition: Edge.hpp:42
auto operator<=>(const Edge &other) const
Definition: Edge.hpp:38
virtual std::string name() const
Definition: Edge.hpp:66
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