Class DataList

java.lang.Object
model.estrutura.DataList

public class DataList extends Object
Represents a FIFO (First-In-First-Out) data structure implemented as a linked list. This class provides operations to write data to the end of the list and read data from the beginning, following the queue principle.

The implementation maintains references to both head and tail nodes for efficient append operations.

Since:
2024
  • Field Details

  • Constructor Details

    • DataList

      public DataList()
      Constructs an empty DataList. Both head and last references are initialized to null.
  • Method Details

    • writeData

      public void writeData(String data)
      Writes (appends) the specified data to the end of the FIFO queue. If the list is empty, the new data becomes both head and last. Otherwise, it's appended after the current last node.
      Parameters:
      data - the string data to be added to the queue
    • readData

      public String readData()
      Reads and removes the data from the beginning of the FIFO queue. Returns "empty.!." if the queue is empty. Following FIFO principle, the first element added is the first one removed.
      Returns:
      the data from the beginning of the queue, or "empty.!." if the queue is empty