Node

package com.thealgorithms.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;
    }
}
Algerlogo

Β© Alger 2022

About us

We are a group of programmers helping each other build new things, whether it be writing complex encryption programs, or simple ciphers. Our goal is to work together to document and model beautiful, helpful and interesting algorithms using code. We are an open-source community - anyone can contribute. We check each other's work, communicate and collaborate to solve problems. We strive to be welcoming, respectful, yet make sure that our code follows the latest programming guidelines.