This project provides the API for a student assignment on implementing stacks and queues. Students are expected to use the interfaces defined in this project to create their own implementations.
This project defines two main interfaces: Stack<E> and Queue<E>.
A Stack is a Last-In-First-Out (LIFO) data structure. The following methods are available:
void push(E e): Add an element to the top of the stack.E pop(): Remove and return the top element from the stack.E peek(): Return, but not remove, the top element from the stack.boolean isEmpty(): Check if the stack is empty.int size(): Get the number of elements in the stack.
A Queue is a First-In-First-Out (FIFO) data structure. The following methods are available:
void add(E e): Add an element to the end of the queue.E remove(): Remove and return the first element from the queue.E peek(): Return, but not remove, the first element in the queue.boolean isEmpty(): Check if the queue is empty.int size(): Get the number of elements in the queue.
A factory is provided to create instances of your stack and queue implementations. You need to implement the StackQueueFactory interface. This factory is used to test your implementations.
Stream<StackQueueConfiguration> streamConfigurations(): This method should return a stream ofStackQueueConfigurationobjects. Each configuration represents a specific implementation of a stack or a queue.
The StackQueueConfiguration interface has the following methods:
boolean isActive(): Whether this implementation should be tested.String getName(): The name of your implementation (e.g., "MyArrayStack").StackQueue getType(): The type of the data structure (StackQueue.STACKorStackQueue.QUEUE).<E> Stack<E> getStack(): Return an instance of yourStackimplementation.<E> Queue<E> getQueue(): Return an instance of yourQueueimplementation.
- Implement the
Stack<E>andQueue<E>interfaces using linked list. - Implement the
StackQueueFactoryto provide your implementations to the testing framework. - Make sure your implementations pass all the tests.
To build this project and install it in your local Maven repository, run the following command:
mvn clean install