package com.gh.download.simple

import java.util.*

/**
 *  A stack that holds fixed size listeners.
 *
 *  You may wonder why using a stack.
 *  I just can't find a proper way to handle these listeners.
 *  If you do have a simple and easy way to achieve the same goal, let me know, please. :)
 */
class FixedSizeStack<T>(private var maxSize: Int) : Stack<T>() {
    override fun push(item: T): T {
        while (this.size >= maxSize) {
            this.removeAt(0)
        }
        return super.push(item)
    }
}