CXXGraph  0.2.0
CXXGraph is a header only, that manages the Graphs and it's algorithm in C++
Node.hpp
1 /***********************************************************/
2 /*** ______ ____ ______ _ ***/
3 /*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/
4 /*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/
5 /*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/
6 /*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/
7 /*** |_| ***/
8 /***********************************************************/
9 /*** Header-Only C++ Library for Graph ***/
10 /*** Representation and Algorithms ***/
11 /***********************************************************/
12 /*** Author: ZigRazor ***/
13 /*** E-Mail: zigrazor@gmail.com ***/
14 /***********************************************************/
15 /*** Collaboration: ----------- ***/
16 /***********************************************************/
17 /*** License: AGPL v3.0 ***/
18 /***********************************************************/
19 
20 
21 #ifndef __NODE_H__
22 #define __NODE_H__
23 
24 #pragma once
25 #include <iostream>
26 
27 namespace CXXGRAPH
28 {
29  template <typename T>
30  class Node;
31  template <typename T>
32  std::ostream &operator<<(std::ostream &os, const Node<T> &node);
33  template <typename T>
34  class Node
35  {
36  private:
37  unsigned long id;
38  T data;
39 
40  public:
41  Node(const unsigned long id, const T &data);
42  ~Node() = default;
43  const unsigned long &getId() const;
44  const T &getData() const;
45  //operator
46  bool operator==(const Node<T> &b) const;
47  bool operator<(const Node<T> &b) const;
48  friend std::ostream &operator<<<>(std::ostream &os, const Node<T> &node);
49  };
50 
51  template <typename T>
52  Node<T>::Node(const unsigned long id, const T &data)
53  {
54  this->id = id;
55  this->data = data;
56  }
57 
58  template <typename T>
59  const unsigned long &Node<T>::getId() const
60  {
61  return id;
62  }
63 
64  template <typename T>
65  const T &Node<T>::getData() const
66  {
67  return data;
68  }
69 
70  template <typename T>
71  bool Node<T>::operator==(const Node<T> &b) const
72  {
73  return (this->id == b.id && this->data == b.data);
74  }
75 
76  template <typename T>
77  bool Node<T>::operator<(const Node<T> &b) const
78  {
79  return (this->id < b.id);
80  }
81 
82 
83  //ostream overload
84  template <typename T>
85  std::ostream &operator<<(std::ostream &os, const Node<T> &node)
86  {
87  os << "Node: {\n"
88  << " Id:\t" << node.id << "\n Data:\t" << node.data << "\n}";
89  return os;
90  }
91 }
92 
93 #endif // __NODE_H__
Definition: Node.hpp:35