#pragma once

#include <queue>
#include <robin_hood.h>
#include <cassert>

namespace data {
    /// Queue discarding duplicate values
    /// @note not thread safe
    template <class T>
    struct unique_queue {
        std::queue<T> queue;
        robin_hood::unordered_flat_set<T> set;

        bool push(T in) {
            if(set.insert(in).second) {
                queue.push(in);
                return true;
            }
            return false;
        }

        T pop() {
            const auto out = queue.front();
            set.erase(out);
            queue.pop();
            return out;
        }

        bool empty() const {
            return queue.empty();
        }

        size_t size() const {
            return queue.size();
        }
    };
}
