.kotlin.kotlin-compiler-client-embeddable.2.1.0.source-code.LimitedLinkedList.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-compiler-client-embeddable Show documentation
Show all versions of kotlin-compiler-client-embeddable Show documentation
Kotlin compiler client embeddable
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.client
import java.util.*
internal class LimitedLinkedList(private val limit: Int) : LinkedList() {
init {
require(limit > 0) {
"The limit shall be > 0. Other values does not make any sense"
}
}
override fun add(element: E): Boolean {
val added = super.add(element)
while (added && size > limit) {
super.remove()
}
return added
}
}