diff --git a/.gitignore b/.gitignore
index 1933432..149dcaf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.attach_pid*
/src/target/
/src/.attach_pid*
+/target
!.mvn/wrapper/maven-wrapper.jar
### sts ###
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..468117b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,41 @@
+
+
+
Java Algorithms and Data Structures
+
+## Table of contents
+- [About the project](#about-the-project)
+- [Description](#description)
+- [Built with](#built-with)
+- [Installation](#installation)
+- [Run](#run)
+- [License](#license)
+
+## About the project
+Basically, it's about algorithms and data structure and was created for the purpose of learning, researching, and recording all the content so that I can return when necessary.
+
+## Description
+This project contains basic implementations using Java so that anyone can learn from examples.
+
+## Built with
+* [Java 8](https://java.com/en/download/help/java8.html)
+* [JUnit 4](https://junit.org/junit4/)
+* [Maven](https://maven.apache.org/)
+
+## Installation
+
+To clone and run this application, you'll need Git installed on your computer(or no, if you want to download **.zip**). From your command line:
+```bash
+# Git CLI
+git clone https://github.com/zevolution/java-algorithms-and-datastructure.git
+
+# Github CLI
+gh repo clone zevolution/java-algorithms-and-datastructure
+```
+
+## Run
+```bash
+mvn test
+```
+
+## License
+[MIT](https://choosealicense.com/licenses/mit/)
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..79c812b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,24 @@
+
+
+ 4.0.0
+
+ br.com.zevolution
+ java-algorithms-and-datastructure
+ 0.0.1-SNAPSHOT
+ java-algorithms-and-datastructure
+ Algorithms and data structures implemented in Java
+
+
+ 1.8
+
+
+
+
+ junit
+ junit
+ 4.12
+
+
+
diff --git a/src/main/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedList.java b/src/main/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedList.java
index 3954268..997996c 100644
--- a/src/main/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedList.java
+++ b/src/main/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedList.java
@@ -58,6 +58,33 @@ public void removeFirst() {
}
}
+ public void remove(Object element) {
+ Node current = this.first;
+ Node previous = null;
+
+ if (current.getElement() == element) {
+ this.first = current.getNext();
+ current = null;
+ this.totalElements--;
+ return;
+ }
+
+ while (current != null) {
+ if (current.getElement() == element) {
+ break;
+ }
+
+ previous = current;
+ current = current.getNext();
+ }
+
+ if (current == null) return;
+
+ previous.setNext(current.getNext());
+ current = null;
+ this.totalElements--;
+ }
+
public Object get(int position) {
return this.getNode(position).getElement();
}
diff --git a/src/test/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedListTest.java b/src/test/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedListTest.java
index 1166a82..e3ee958 100644
--- a/src/test/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedListTest.java
+++ b/src/test/java/br/com/zevolution/datastructure/linkedlist/CustomLinkedListTest.java
@@ -93,4 +93,18 @@ public void should_ThrowException_When_NoSuchElement() {
linkedList.removeFirst();
}
+ @Test
+ public void should_RemoveMiddleElement() {
+ CustomLinkedList linkedList = new CustomLinkedList();
+ linkedList.add("Bia");
+ linkedList.add("Lucas");
+ linkedList.add("Laura");
+
+ linkedList.remove("Lucas");
+
+ assertEquals(2, linkedList.size());
+ assertEquals("Bia", linkedList.get(0));
+ assertEquals("Laura", linkedList.get(1));
+ }
+
}