18.10.2014 Views

COSC 1P03 Data Structures and Abstraction 18.1

COSC 1P03 Data Structures and Abstraction 18.1

COSC 1P03 Data Structures and Abstraction 18.1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>COSC</strong> <strong>1P03</strong><br />

<strong>Data</strong> <strong>Structures</strong> <strong>and</strong> <strong>Abstraction</strong><br />

<strong>COSC</strong> <strong>1P03</strong><br />

Java Collections Framework<br />

<br />

<br />

Queue interface<br />

generic in element type (E)<br />

some duplication of methods (Collection)<br />

st<strong>and</strong>ard queue methods<br />

add = enter<br />

remove = leave<br />

element = front<br />

size = length<br />

isEmpty = empty<br />

LinkedList class<br />

generic in element type (E)<br />

implements Queue as symmetrically-linked structure<br />

also implements List<br />

<strong>Data</strong> <strong>Structures</strong> <strong>and</strong> <strong>Abstraction</strong> <strong>18.1</strong>0<br />

package java.util;<br />

public interface Queue < E > extends Collection {<br />

public boolean add ( E o ); // from Collection<br />

public void clear ( ); // from Collection<br />

public boolean contains ( Object o ); // from Collection<br />

public E element ( );<br />

public boolean equals ( Object o ); // from Collection<br />

public boolean isEmpty ( ); // from Collection<br />

public Iterator iterator ( ); // from Collection<br />

public boolean offer ( E o );<br />

public E peek ( );<br />

public E poll ( );<br />

public E remove ( );<br />

public boolean remove ( Object o ); // from Collection<br />

public int size ( ); // from Collection<br />

public Object[] toArray ( ); // from Collection<br />

} // Queue<br />

18.4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!