BoundedPriorityBuffer

com.netflix.atlas.core.util.BoundedPriorityBuffer
class BoundedPriorityBuffer[T <: AnyRef](maxSize: Int, comparator: Comparator[T])

Fixed size buffer that can be used for computing the top-K items.

Value parameters

comparator

Comparator used for checking the relative priority of entries.

maxSize

Maximum size of the buffer.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def add(value: T): T

Add a value into the buffer if there is space or it has a higher priority than the lowest priority item currently in the buffer. If it has the same priority as the lowest priority item, then the previous value will be retained and the new value will be rejected.

Add a value into the buffer if there is space or it has a higher priority than the lowest priority item currently in the buffer. If it has the same priority as the lowest priority item, then the previous value will be retained and the new value will be rejected.

Value parameters

value

Value to attempt to add into the buffer.

Attributes

Returns

The return value is either: a) a value that was ejected because of the new addition, b) the value that was passed in if it wasn't high enough priority, or c) null if the max size has not yet been reached.

def drainToOrderedList(): List[T]

Drain elements to a list that is ordered by priority.

Drain elements to a list that is ordered by priority.

Attributes

def foreach(f: T => Unit): Unit

Invoke the function f for all items in the buffer.

Invoke the function f for all items in the buffer.

Attributes

def size: Int

Number of items in the buffer.

Number of items in the buffer.

Attributes

def toList: List[T]

Return a list containing all of the items in the buffer.

Return a list containing all of the items in the buffer.

Attributes