Skip to content

Commit

Permalink
Updated the double_node class
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepiCaffeine committed Jun 20, 2023
1 parent 2251c70 commit 5502958
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions Data Structures/double_node.h → Data Structures/double_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
template <typename T>
class double_node {

protected:
double_node<T>* next;
double_node<T>* prev;
T data;
protected:
double_node<T>* next; /**< Pointer to the next node [double_node<T>]*/
double_node<T>* prev; /**< Pointer to the previous node [double_node<T>*]*/
T data; /**< Data which is stored in the Node [T]*/

public:
/**
Expand Down Expand Up @@ -73,7 +73,9 @@ class double_node {
* @see double_node(double_node<T>* const nnd, double_node<T>* const bnd, const T dt)
*/
double_node(double_node<T>* const nd)
: next{nd}, prev{nullptr} { }
: next{nd}, prev{nullptr} {
nd->set_prev(this);
}

/**
* Creates a new double_node object that points to a double_node, and has data.
Expand All @@ -89,7 +91,9 @@ class double_node {
* @see double_node(double_node<T>* const nnd, double_node<T>* const bnd, const T dt)
*/
double_node(double_node<T>* const nd, const T dt)
: next{nd}, data{dt} { };
: next{nd}, data{dt} {
nd->set_prev(this);
};

/**
* Creates a new double_node object that points to 2 double_nodes, but has no data.
Expand All @@ -105,7 +109,10 @@ class double_node {
* @see double_node(double_node<T>* const nnd, double_node<T>* const bnd, const T dt)
*/
double_node(double_node<T>* const nnd, double_node<T>* const bnd)
: next{nnd}, prev{bnd} {}
: next{nnd}, prev{bnd} {
//nnd->set_prev(this);
//bnd->set_next(this);
}


/**
Expand All @@ -123,7 +130,10 @@ class double_node {
* @see double_node(double_node<T>* const nnd, double_node<T>* const bnd)
*/
double_node(double_node<T>* const nnd, double_node<T>* const bnd, const T dt)
: next{nnd}, prev{bnd}, data{dt} {}
: next{nnd}, prev{bnd}, data{dt} {
//nnd->set_prev(this);
//bnd->set_next(this);
}

/**
* Construct a new double_node object from another double_node object.
Expand Down Expand Up @@ -193,32 +203,32 @@ double_node<T>::double_node(const double_node<T>& nd) {

template <typename T>
void double_node<T>::set_prev(double_node<T>* const nd) {
this->prev = nd;
prev = nd;
}

template <typename T>
double_node<T>* double_node<T>::get_prev() const {
return this->prev;
return prev;
}

template <typename T>
void double_node<T>::set_next(double_node<T>* const nd) {
this->next = nd;
next = nd;
}

template <typename T>
double_node<T>* double_node<T>::get_next() const {
return this->next;
return next;
}

template <typename T>
T double_node<T>::get_data() const {
return this->data;
return data;
}

template <typename T>
void double_node<T>::set_data(const T dt) {
this->data = dt;
data = dt;
}

#endif // DOUBLE_NODE_H

0 comments on commit 5502958

Please sign in to comment.