package com.knecon.fforesight.service.layoutparser.processor.services.graphics;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

public class DistinctQueue<T> {

    private Queue<T> queue;
    private Set<T> set;


    public DistinctQueue() {

        queue = new LinkedList<>();
        set = new HashSet<>();
    }


    public void enqueue(T element) {

        if (!set.contains(element)) {
            queue.add(element);
            set.add(element);
        }
    }


    public T dequeue() {

        T element = queue.poll();
        if (element != null) {
            set.remove(element);
        }
        return element;
    }


    public boolean isEmpty() {

        return queue.isEmpty();
    }


    public int size() {

        return queue.size();
    }
    // Other methods as needed
}