Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.NoSuchElementException;
- public class FIFO implements Queue {
- ArrayList Jens = new ArrayList();
- private int störstaJens;
- public FIFO() {
- störstaJens = 0;
- }
- public void add(Object arg0) {
- Jens.add(arg0);
- if(Jens.size() > störstaJens)
- {
- störstaJens = Jens.size();
- }
- }
- public Object first() throws NoSuchElementException {
- if(Jens.size() < 0)
- {
- throw new NoSuchElementException();
- }
- return Jens.get(0);
- }
- public boolean isEmpty() {
- return Jens.isEmpty();
- }
- public int maxSize() {
- return störstaJens;
- }
- public void removeFirst() throws NoSuchElementException {
- if(Jens.size() > 0)
- {
- Jens.remove(0);
- }
- else
- {
- throw new NoSuchElementException();
- }
- }
- public int size() {
- return Jens.size();
- }
- public String toString() {
- return "";
- }
- public boolean equals(Object f) {
- if(f instanceof FIFO)
- {
- if(this.size() == ((FIFO) f).size())
- {
- for(int i = 0; i <= Jens.size(); i++)
- {
- if(this.Jens.get(i) != null && ((FIFO) f).Jens.get(i) != null)
- {
- System.out.println("Hax!");
- }
- }
- }
- {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement