/** * This class implements a singly linked list of floats in Java. * @author Jon Schlegel * @version 1.0 */ public class FloatLinkedList { protected Node head; protected Node tail; /** * Constructs a new singly linked list object. */ public FloatLinkedList() { head = null; tail = null; } /** * Removes all of the elements from the linked list. */ public void removeAllElements() { head = null; tail = null; } /** * Adds a node containing the float to the beginning of the * list. * @param f The float to be added to the list. */ public void addNode(float f) { Node new_node = new Node(f); // If the list is empty, set the head and tail correctly. if (head == null) { head = new_node; tail = head; return; } tail.setNext(new_node); tail = new_node; } /** * Deletes the ith node in the list. * @param i The number of the node in the list to delete. * @return True if the deletion was successful, false if the ith node * could not be deleted (e.g. if the list contains less than * i nodes). */ public boolean deleteNodeAt(int i) { // Handle the empty list and negative values of i. if (head == null || i<0) return false; // Delete the head of the list if (i==0) { head = head.getNext(); if (head == null) tail = null; return true; } Node temp = head; for (int node_num = 0;node_num