javas built in PriorityQueue object does not do what it should.
it actually functions as a stack (first object in last out)

so I cooked up my own FIFO (first in first out) queue
than I also replaced the old PriorityQueue usage in the Fusion and FusioCera classes of the livingrimoire for safe measure.

but this class functions as a stand alone. it does not require dependency classes to work.

this is how a queue needs to be. the first in the queue has the most priority to be polled next.

Code:

package LivinGrimoire;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

public class LGFIFO <T>{
    //first in first out queue
    protected ArrayList<T> elements = new ArrayList<T>();
    public void add(T item){
        elements.add(item);
    }
    public int size(){
        return elements.size();
    }
    public T peak(){
        if(size() == 0){
            return null;
        }
        return elements.get(0);
    }
    public T poll(){
        if(size() == 0){
            return null;
        }
        T result = elements.get(0);
        elements.remove(0);
        return result;
    }
    public void removeItem(T item){
        if(elements.contains(item)){
        elements.remove(item);}
    }
    public void clear(){
        elements.clear();
    }
    private Random rand = new Random();
    public T getRNDElement(){
        return  elements.get(rand.nextInt(elements.size()));
    }
    public boolean contains(T input){
        return elements.contains(input);
    }
    public Boolean isEmpty(){
        return elements.isEmpty();
    }
    public void remove(T element){
        elements.remove(element);
    }
    public Iterator<T> iterator(){
        return elements.iterator();
    }

    public ArrayList<T> getElements() {
        return elements;
    }
}


thug_life



https://github.com/yotamarker/public-livinGrimoire/blob/master/livingrimoire%20start%20here/LivinGrimoire%20java/LivinGrimoire/LGFIFO.java