diff --git a/src/List.java b/src/List.java index 413d20f..586a4d5 100644 --- a/src/List.java +++ b/src/List.java @@ -1,5 +1,8 @@ public class List implements IList { + /** + * Node for handling the list. + */ private class Node { private T item; private Node next; @@ -15,8 +18,14 @@ } } + /** + * Contains the root node. + */ private Node root; + /** + * Add an element at a specific position starting at 0. + */ public void addAt(int pos, T elem) { if (root == null) { root = new Node(elem); @@ -37,6 +46,9 @@ } } + /** + * Remove an element at a position. + */ public boolean removeAt(int pos) { boolean isRemoved = false; if (root != null) { @@ -61,6 +73,9 @@ return isRemoved; } + /** + * Find an item in the list of type T. + */ public int find(T elem) { int returnValue = 0; @@ -77,6 +92,9 @@ return returnValue; } + /** + * Return the current size of the list. + */ public int size() { int returnValue = 0; Node walker = root; @@ -87,6 +105,9 @@ return returnValue; } + /** + * Remove all elements. + */ public void clear() { while (root != null) { Node temp = root.next; @@ -99,6 +120,9 @@ } + /** + * Returns an array of strings with all elements. + */ public String[] getAllElementsAsStrings() { int size = size(); String[] list = new String[size];