Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Latest commit

 

History

History
History
35 lines (28 loc) · 739 Bytes

File metadata and controls

35 lines (28 loc) · 739 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.ArrayList;
public class Queue <T>{
private ArrayList <T> queue;
Queue() {
queue = new ArrayList<T>();
}
public void enqueue(T element){
queue.add(element);
}
public boolean isEmpty(){
return (queue.size() < 1);
}
public T dequeue() throws EmptyQueueException{
if(isEmpty()){
throw new EmptyQueueException("Dequeue");
}
else{
T element = queue.get(0);
queue.remove(0);
return element;
}
}
}
class EmptyQueueException extends Exception{
public EmptyQueueException(String action){
super("Queue is empty. Underflow.Cannot perform action " + action);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.