LAB B - public interface EntryWayListInterface cfw_ /*...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
public interface EntryWayListInterface { /** @param newEntry * @return true or false */ public boolean insertHead (Object newEntry); /** @param newEntry * @return true or false */ public boolean insertTail (Object newEntry); /** @return Object */ public Object deleteHead(); /** @return Object */ public Object deleteTail(); /** Task: Display list on the screen */ void display(); /** @param newEntry * @return integer value */ int contains(Object anEntry); /** @return true or false */ boolean isEmpty(); /** @return true or false */ boolean isFull(); } public class LList implements EntryWayListInterface { private Node firstNode ; private int length ; public LList(){ firstNode = null ; length = 0; } public int contains(Object anEntry) { Node currentNode = firstNode ; Node newNode = new Node(anEntry); int count = 0, position = 0; while (currentNode != null ){ count++; if (newNode. data == currentNode. data ) position = count; currentNode = currentNode. next ; } return position; } public Object deleteHead() { if (!isEmpty() && length > 1){ Node oldFirstNode = firstNode ;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
firstNode = firstNode . next ; length --; return oldFirstNode;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2012 for the course CS 111C taught by Professor Metzler during the Spring '11 term at City College of San Francisco.

Page1 / 5

LAB B - public interface EntryWayListInterface cfw_ /*...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online