Skip to content

Commit

Permalink
Merge branch 'sp/#339-em-it' into all/#tbw
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter committed Sep 25, 2022
2 parents a355ea7 + ef77363 commit 7d52207
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/scala/edu/ie3/simona/agent/ValueStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,15 @@ object ValueStore {
valueStore: ValueStore[D],
tick: Long,
newEntry: D
): ValueStore[D] = valueStore.copy(
store = (valueStore.store + (tick -> newEntry))
.filter(pair => pair._1 > tick - valueStore.maxTickSpan)
)
): ValueStore[D] = {
val updatedStore = valueStore.store + (tick -> newEntry)

valueStore.copy(
store =
if (updatedStore.size > 5) // always keep at least 5 entries
updatedStore.filter(pair => pair._1 > tick - valueStore.maxTickSpan)
else
updatedStore
)
}
}

0 comments on commit 7d52207

Please sign in to comment.