Skip to content

FontysVenlo/alda_queue_stack_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stacks and Queues API

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.

API

This project defines two main interfaces: Stack<E> and Queue<E>.

Stack<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.

Queue<E>

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.

Factory

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 of StackQueueConfiguration objects. 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.STACK or StackQueue.QUEUE).
  • <E> Stack<E> getStack(): Return an instance of your Stack implementation.
  • <E> Queue<E> getQueue(): Return an instance of your Queue implementation.

Student Assignment

  1. Implement the Stack<E> and Queue<E> interfaces using linked list.
  2. Implement the StackQueueFactory to provide your implementations to the testing framework.
  3. Make sure your implementations pass all the tests.

Building the API project

To build this project and install it in your local Maven repository, run the following command:

mvn clean install