DecayingValue class

A decaying tag is one whose value automatically decays over time.

The actual application of the decay behaviour is encapsulated in a user-provided decaying function (DecayFn). The function is called on every tick (determined by the interval parameter), and returns either the new value of the tag, or whether it should be erased altogether.

We do not set values on a decaying tag. Rather, we "bump" decaying tags by a delta. This calls the BumpFn with the old value and the delta, to determine the new value.

Such a pluggable design affords a great deal of flexibility and versatility. Behaviours that are straightforward to implement include:

  • Decay a tag by -1, or by half its current value, on every tick.
  • Every time a value is bumped, sum it to its current value.
  • Exponentially boost a score with every bump.
  • Sum the incoming score, but keep it within min, max bounds. Represents a value for a decaying tag.

Constructors

DecayingValue.new({required DecayingTag tag, required PeerId peer, DateTime? added, DateTime? lastVisit, int value = 0})

Properties

added DateTime
Added is the timestamp when this value was added for the first time for a tag and a peer.
final
hashCode int
The hash code for this object.
no setterinherited
lastVisit DateTime
LastVisit is the timestamp of the last visit.
final
peer PeerId
Peer is the peer ID to whom this value is associated.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tag DecayingTag
Tag points to the tag this value belongs to.
final
value int
Value is the current value of the tag.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited