Package org.cis1200
Class PointQueue
java.lang.Object
org.cis1200.PointQueue
This is an implementation of a Queue in Java that uses a built-in data
structure about which we haven't learned yet. You should assume that it
works just like our Queues in OCaml. Each element in the queue is an array
of two ints.
This class will be useful to you when you write the flood() function in
Manipulate.java.
You do not need to modify this file.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int[] v) Add an element to the queue.boolean
contains
(int[] c) Determines whether the queue contains a given value.deepCopy()
Get a copy of the queue.int[]
get
(int index) Get an element from the queue.boolean
isEmpty()
Determine whether the queue is empty.int[]
remove
(int index) Remove an element from the queue.int
size()
Retrieves the size of the queue.
-
Constructor Details
-
PointQueue
public PointQueue()
-
-
Method Details
-
add
public void add(int[] v) Add an element to the queue.- Parameters:
v
- The int array to add to the queue.
-
isEmpty
public boolean isEmpty()Determine whether the queue is empty.- Returns:
- true if the queue is empty; false otherwise.
-
remove
public int[] remove(int index) Remove an element from the queue.- Parameters:
index
- The (zero-based) position of the element to be removed.- Returns:
- The element that was removed from the list.
-
size
public int size()Retrieves the size of the queue.- Returns:
- The size of the queue.
-
contains
public boolean contains(int[] c) Determines whether the queue contains a given value.- Parameters:
c
- The value to check for existence.- Returns:
- true if the value is in the queue; false otherwise.
-
get
public int[] get(int index) Get an element from the queue.- Parameters:
index
- The location of the element to get.- Returns:
- The element at the given location in the queue.
-
deepCopy
Get a copy of the queue.- Returns:
- A deep copy of the queue.
-