Improved GenerationalQueue: using a list of buckets responsible for containing elements belonging to a slice of time.
Generational Queue keep track of elements based on their last activity.
Generational Queue keep track of elements based on their last activity. You can refresh activity of an element by calling touch(a: A) on it. There is 2 ways of retrieving old elements: - collect(age: Duration) collect the oldest element (age of elem must be > age) - collectAll(age: Duration) collect all the elements which age > age in parameter
RecordSchema represents the declaration of a heterogeneous Record type, with Fields that are determined at runtime.
RecordSchema represents the declaration of a heterogeneous Record type, with Fields that are determined at runtime. A Field declares the static type of its associated values, so although the record itself is dynamic, field access is type-safe.
Given a RecordSchema declaration schema
, any number of
Records of that schema can be obtained with
schema.newRecord
. The type that Scala assigns to this value is what Scala calls a
"path-dependent type," meaning that
schema1.Record
and schema2.Record
name distinct types. The same is true of fields:
schema1.Field[A]
and schema2.Field[A]
are distinct, and can only be used with the
corresponding Record.
Improved GenerationalQueue: using a list of buckets responsible for containing elements belonging to a slice of time. For instance: 3 Buckets, First contains elements from 0 to 10, second elements from 11 to 20 and third elements from 21 to 30 We expand the list when we need a new bucket, and compact the list to stash all old buckets into one. There is a slightly difference with the other implementation, when we collect elements we only choose randomly an element in the oldest bucket, as we don't have activity date in this bucket we consider the worst case and then we can miss some expired elements by never find elements that aren't expired.