mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
Add generic Node classes (#2782)
Co-authored-by: Andrii Siriak <siryaka@gmail.com>
This commit is contained in:
committed by
GitHub
parent
78f770683a
commit
7f3eb1b6dc
36
DevUtils/Nodes/Node.java
Normal file
36
DevUtils/Nodes/Node.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package DevUtils.Nodes;
|
||||
|
||||
/**
|
||||
* Base class for any node implementation which
|
||||
* contains a generic type variable.
|
||||
*
|
||||
* All known subclasses: {@link TreeNode}, {@link SimpleNode}.
|
||||
*
|
||||
* @param <E> The type of the data held in the Node.
|
||||
*
|
||||
* @author <a href="https://github.com/aitorfi">aitorfi</a>
|
||||
*/
|
||||
public abstract class Node<E> {
|
||||
/** Generic type data stored in the Node. */
|
||||
private E data;
|
||||
|
||||
/** Empty constructor. */
|
||||
public Node() {}
|
||||
|
||||
/**
|
||||
* Initializes the Nodes' data.
|
||||
*
|
||||
* @param data Value to which data will be initialized.
|
||||
*/
|
||||
public Node(E data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public E getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(E data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user