impl: custom linked list
This commit is contained in:
@@ -27,6 +27,21 @@ public class CustomLinkedListImpl<T> implements CustomLinkedList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private CustomLinkedListNode<T> traverseFind(CustomLinkedListNode<T> currentNode, T item) {
|
||||
|
||||
CustomLinkedListNode<T> 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<T> implements CustomLinkedList<T> {
|
||||
|
||||
@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<T> node, int count) {
|
||||
|
||||
Reference in New Issue
Block a user