Skip to content

Commit

Permalink
Removed unnecessary constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepiCaffeine committed Jun 23, 2023
1 parent e792388 commit b95b9b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
6 changes: 3 additions & 3 deletions Data Structures/double_node.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* @file double_node.h
* @file double_node.hpp
* @author Vakaris Michejenko (sleepicaffeine@gmail.com)
* @brief A header that defines a dynamic double_node class
* @version 0.21
* @date 2023-06-21
* @version 0.3
* @date 2023-06-24
* @copyright Copyright (c) 2023
* @link https://github.com/SleepiCaffeine
*/
Expand Down
34 changes: 7 additions & 27 deletions Data Structures/node.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* @file node.h
* @file node.hpp
* @author Vakaris Michejenko (sleepicaffeine@gmail.com)
* @brief A header that defines a dynamic node class
* @version 0.21
* @date 2023-06-21
* @version 0.3
* @date 2023-06-24
* @copyright Copyright (c) 2023
* @link https://github.com/SleepiCaffeine
*/
Expand All @@ -20,7 +20,6 @@
* @fn set_data(T dt)
* @fn get_next()
* @fn set_next(Node<T>* nd)
* @fn forward()
* @tparam T typename
*/
template <typename T>
Expand Down Expand Up @@ -54,15 +53,6 @@ class node {
node(node<T>* const nd, const T dt)
: next{nd}, data{dt} { }

/**
* Creates a new node that points to a node in both ways, and has data.
* @brief Constructor.
* @param nnd node to which it points to next.
* @param dt node data.
*/
node(node<T>* const nnd, node<T>*, const T dt)
: next{nnd}, data{dt} { }

/**
* Construct a new node from another node object.
* @brief Copy constructor.
Expand All @@ -77,41 +67,31 @@ class node {
* @return node data.
*/
T get_data() const {
return this->data;
return data;
}

/**
* @brief Set the current node's data.
* @param dt new node data.
*/
void set_data(const T dt) {
this->data = dt;
data = dt;
}

/**
* @brief Get the pointer to the next node.
* @return node object to which the current node object points to next.
*/
node<T>* get_next() const {
return this->next;
return next;
}

/**
* @brief Set the pointer to the next node.
* @param nd new node object to which the current node object will point to next.
*/
void set_next(node<T>* const nd) {
this->next = nd;
}

/**
* @brief Set current node to the next node.
*/
void forward() {
if (this->next) {
this->data = next->get_data();
this->next = next->get_next();
}
next = nd;
}
};

Expand Down

0 comments on commit b95b9b8

Please sign in to comment.