FrequencyTrackingRingBuffer

class FrequencyTrackingRingBuffer(maxSize: Int, sentinel: Int) : Accountable

A ring buffer that tracks the frequency of the integers that it contains. This is typically useful to track the hash codes of popular recently-used items.

This data-structure requires 22 bytes per entry on average (between 16 and 28).

Constructors

Link copied to clipboard
constructor(maxSize: Int, sentinel: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).

Functions

Link copied to clipboard
fun add(i: Int)

Add a new item to this ring buffer, potentially removing the oldest entry from this buffer if it is already full.

Link copied to clipboard
Link copied to clipboard
fun frequency(key: Int): Int

Returns the frequency of the provided key in the ring buffer.

Link copied to clipboard
open override fun ramBytesUsed(): Long

Return the memory usage of this object in bytes. Negative values are illegal.