Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNEMONIC-820: Enhanced Node Class #380

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,62 @@

package org.apache.mnemonic.bench;

/**
* Represents a node in a linked list.
*
* @param <T> the type of data stored in the node
*/
public class Node<T> {

T data;
Node<T> nextNode;

public Node(T data) {
this.data = data;
this.nextNode = null;
}

public Node(T data, Node<T> node) {
this.data = data;
this.nextNode = node;
}

public T getData() {
return this.data;
}

public void setNext(Node<T> node) {
this.nextNode = node;
}

public Node<T> getNext() {
return this.nextNode;
}
private T data; // The data stored in the node
private Node<T> nextNode; // Reference to the next node in the list

/**
* Constructs a new node with the given data.
*
* @param data the data to be stored in the node
*/
public Node(T data) {
this.data = data;
this.nextNode = null;
}

/**
* Constructs a new node with the given data and reference to the next node.
*
* @param data the data to be stored in the node
* @param nextNode the next node in the list
*/
public Node(T data, Node<T> nextNode) {
this.data = data;
this.nextNode = nextNode;
}

/**
* Gets the data stored in the node.
*
* @return the data stored in the node
*/
public T getData() {
return this.data;
}

/**
* Sets the reference to the next node.
*
* @param nextNode the next node in the list
*/
public void setNext(Node<T> nextNode) {
this.nextNode = nextNode;
}

/**
* Gets the next node in the list.
*
* @return the next node in the list
*/
public Node<T> getNext() {
return this.nextNode;
}
}

Loading