From 3a78f9a51d3d66ffd32a1ad1ab2a7ae60fb1790c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20P=C5=99ib=C3=ADk?= Date: Thu, 16 Oct 2025 15:27:25 +0200 Subject: [PATCH] impl: custom linked list --- .../customlist/CustomLinkedListImpl.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/assignment/src/main/java/appointmentplanner/customlist/CustomLinkedListImpl.java b/assignment/src/main/java/appointmentplanner/customlist/CustomLinkedListImpl.java index ef2ed46..1e82fd8 100644 --- a/assignment/src/main/java/appointmentplanner/customlist/CustomLinkedListImpl.java +++ b/assignment/src/main/java/appointmentplanner/customlist/CustomLinkedListImpl.java @@ -27,6 +27,21 @@ public class CustomLinkedListImpl implements CustomLinkedList { } } + private CustomLinkedListNode traverseFind(CustomLinkedListNode currentNode, T item) { + + CustomLinkedListNode nextNode = currentNode.getNext(); + + if (nextNode == null) { + return null; + } + + if (currentNode.getItem().equals(item)) { + return currentNode; + } + + return traverseFind(nextNode, item); + } + @Override public void remove(T item) { // TODO Auto-generated method stub @@ -59,8 +74,7 @@ public class CustomLinkedListImpl implements CustomLinkedList { @Override public boolean contains(T item) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'contains'"); + return traverseFind(head, item) != null ? true : false; } private int recursiveSizeCalc(CustomLinkedListNode node, int count) {