@Test public void testContainsEmptyList() { IntSinglyLinkedList list = new IntSinglyLinkedList(); assertFalse(list.contains(0)); }
public boolean contains(int item) { if(head == null) { return false; } else { for(IntNode cur = head; cur != null; cur = cur.next) { if(cur.item == item) { return true; } } return false; } }
IntSinglyLinkedList implements Serializable, Iterable<Integer> { public boolean contains(int item) { if(head == null) { return false; } else { for(IntNode cur = head; cur != null; cur = cur.next) { if(cur.item == item) { return true; } } return false; } } }
IntSinglyLinkedList implements Serializable, Iterable<Integer> { public boolean contains(int item) { if(head == null) { return false; } else { for(IntNode cur = head; cur != null; cur = cur.next) { if(cur.item == item) { return true; } } return false; } } IntSinglyLinkedList(); }
IntSinglyLinkedList implements Serializable, Iterable<Integer> { public boolean contains(int item) { if(head == null) { return false; } else { for(IntNode cur = head; cur != null; cur = cur.next) { if(cur.item == item) { return true; } } return false; } } IntSinglyLinkedList(); int size(); boolean contains(int item); void addLast(int item); void addFirst(int item); boolean isEmpty(); void clear(); int pop(); int peek(); void push(int item); int dequeue(); int getFirst(); void enqueue(int item); int[] toArray(); Integer[] toObjArray(); @Override String toString(); @Override boolean equals(Object other); @Override int hashCode(); @Override IntListIterator iterator(); }
IntSinglyLinkedList implements Serializable, Iterable<Integer> { public boolean contains(int item) { if(head == null) { return false; } else { for(IntNode cur = head; cur != null; cur = cur.next) { if(cur.item == item) { return true; } } return false; } } IntSinglyLinkedList(); int size(); boolean contains(int item); void addLast(int item); void addFirst(int item); boolean isEmpty(); void clear(); int pop(); int peek(); void push(int item); int dequeue(); int getFirst(); void enqueue(int item); int[] toArray(); Integer[] toObjArray(); @Override String toString(); @Override boolean equals(Object other); @Override int hashCode(); @Override IntListIterator iterator();  }