Update Queue.java

This commit is contained in:
yanglbme 2019-03-06 08:58:35 +08:00 committed by GitHub
parent 965c288b3a
commit 481be6290c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,21 +7,39 @@ import java.util.NoSuchElementException;
* Interface to provide queue specific functionality to the implementing class
* This interface only defines the functionality which the queue implementing classes require.
* Any class having queue behaviour should implement this interface and override all of its methods
*
* @param <T>
*/
public interface Queue<T> extends DataStructure<T> {
//Method to add element
public boolean offer(T t) throws NullPointerException;
/**
* Method to add element
*
* @param t element
* @return boolean
* @throws NullPointerException
*/
boolean offer(T t) throws NullPointerException;
//Method to remove element
public T poll();
//Method to check element on head
public T peek();
//Method to check element on head. This throws exception on runtime if the queue is empty
public T element() throws NoSuchElementException;
/**
* Method to remove element
*
* @return element
*/
T poll();
/**
* Method to check element on head
*
* @return element
*/
T peek();
/**
* Method to check element on head. This throws exception on runtime if the queue is empty
*
* @return element
* @throws NoSuchElementException
*/
T element() throws NoSuchElementException;
}