package com.gh.gamecenter.common.utils

class FixedSizeLinkedHashSet<T>(var maxSize: Int) : LinkedHashSet<T>() {
    override fun add(element: T): Boolean {
        if (size == maxSize) {
            pop()
        }
        return super.add(element)
    }

    private fun pop() {
        if (size > 0) {
            remove(iterator().next())
        }
    }
}