File tree Expand file tree Collapse file tree
src/main/java/com/thealgorithms/datastructures/lists Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,11 +33,7 @@ public SelfOrganizingLinkedList() {
3333 this .head = null ;
3434 }
3535
36- /**
37- * Inserts a new value at the end of the list.
38- *
39- * @param value the item to insert
40- */
36+ /** Inserts a new value at the end of the list. */
4137 public void insert (E value ) {
4238 LinkedList <E > newNode = new LinkedList <>(value );
4339 if (head == null ) {
@@ -63,7 +59,6 @@ public boolean search(E key) {
6359 if (head == null ) {
6460 return false ;
6561 }
66-
6762 if (Objects .equals (head .value , key )) {
6863 return true ;
6964 }
@@ -83,35 +78,22 @@ public boolean search(E key) {
8378 prev .next = curr .next ;
8479 curr .next = head ;
8580 head = curr ;
86-
8781 return true ;
8882 }
8983
90- /**
91- * Gets the current head of the list.
92- *
93- * @return value at head, or null if list is empty
94- */
84+ /** Gets the current head of the list. */
9585 public E getHeadValue () {
9686 return head != null ? head .value : null ;
9787 }
9888
99- /**
100- * Returns the size of the list.
101- *
102- * @return number of elements
103- */
89+ /** Returns the size of the list. */
10490 public int getSize () {
10591 return size ;
10692 }
107- /**
108- * Returns true if the list contains no elements.
109- *
110- * @return true if empty
111- */
93+
94+ /** Returns true if the list contains no elements. */
11295 public boolean isEmpty () {
11396 return head == null ;
11497 }
11598}
11699
117-
You can’t perform that action at this time.
0 commit comments