diff --git a/README.md b/README.md index 75444ce..7172724 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # data-strucutures-java Data Structures implemented in Java. -This project will evolve with future improvments in the DS implementation, test coverage and code quality. +This project will evolve with future improvments in the DS implementation, test coverage and code quality so be with us. We will bring more solutions, sloved problems on data structure using java. Thank you. diff --git a/src/main/java/com/leonardoz/datastructures/SimplyLinkedList.java b/src/main/java/com/leonardoz/datastructures/SimplyLinkedList.java index 5c4052d..d0511eb 100644 --- a/src/main/java/com/leonardoz/datastructures/SimplyLinkedList.java +++ b/src/main/java/com/leonardoz/datastructures/SimplyLinkedList.java @@ -1,7 +1,8 @@ package com.leonardoz.datastructures; public class SimplyLinkedList implements LinkedList { - + +// class to create a node of the linked list. static class Node { E value = null; Node next = null; @@ -35,7 +36,7 @@ public void insert(E value) { size++; } - +// inserting the given 'value' at the given 'position'. @Override public void insertAt(E value, int position) throws IllegalArgumentException { if (position > size) { @@ -62,7 +63,7 @@ public void insertAt(E value, int position) throws IllegalArgumentException { size++; } - +// remove value from the given position of a linked list. @Override public E removeAt(int position) throws IllegalArgumentException { if (position > size) { @@ -75,7 +76,7 @@ public E removeAt(int position) throws IllegalArgumentException { first = first.next; return aux.value; } else if (position == (size - 1)) { - // recupera o previous ao último + // recupera o previous ao último Node Node = getNode(position - 1); Node.next = null; Node aux = last; @@ -88,7 +89,7 @@ public E removeAt(int position) throws IllegalArgumentException { return removed.value; } } - +// returns the element from the given position. @Override public E getAt(int position) throws IllegalArgumentException { if (position > size) { @@ -96,7 +97,7 @@ public E getAt(int position) throws IllegalArgumentException { } return getNode(position).value; } - +// returns the node of the given position private Node getNode(int position) { if (position == 0) { return first; @@ -112,17 +113,17 @@ private Node getNode(int position) { return aux; } } - +// returns the first element of the linked list. @Override public E getFirst() { return first.value; } - +// returns the last elemetn of the linked list. @Override public E getLast() { return last.value; } - +// returns the total number of nodes or length of the linked list. @Override public int getSize() { return size;