Description
Write a method void reverseClump(Clump<String> clump) that takes a Clump as argument and uses a stack to reverse the...
Write a method void reverseClump(Clump<String> clump) that takes
a Clump as argument and uses a stack to reverse the order of
the elements in the Clump.
A Clump is a non-descript linear data structure that operates
as a FIFO. It has a put() method that adds elements to one
end of the clump, and a get() method that removes and returns
an element from the other end of the clump. These two methods implement
a first-in first-out policy. It also has a size() method the
returns the number of elements stored in the clump.
Stack<T> to reverse the elements. new Stack<String>().reverseClump() modifies the clump resulting with
the same values in reverse order.Clump object, just reuse the same one.clump is never null, but might be empty.For reference, a Clump is defined as shown below.
public class Clump<E> {
public void put(E v) {...}
public E get() {...}
public int size() {...}
}
For reference, a Stack is defined as shown below.
public class Stack<T> {
public boolean push(T it) {...}
public T pop() {...}
public T peek() {...}
public int size() {...}
public boolean isEmpty() {...}
}
Your feedback will appear here when you check your answer.