PriorityCache.getUpdateOrCreate

Updates the priority of an item if it already existed or creates a new item with the given priority if it didn't exist.

Beware that in case an item didn't exist it is still possible that a new item will NOT be created if whenNewAndLeastPriority() implementation prefers the already existing item over the new one. The default implementation of whenNewAndLeastPriority() always creates a new one.

class PriorityCache(T)
T*
getUpdateOrCreate
(
hash_t key
,
ulong priority
,
out bool existed
,
bool tracK_get_miss = true
)
out (val) { if (existed) { assert (val !is null, "Null return value although item exists"); } }

Parameters

key hash_t

item's key

priority ulong

the priority to update for the existing item or to assign to the new item

existed bool

will be assigned to true if the item already existed and wasn't created

tracK_get_miss bool

flags whether not finding the item should count as a cache miss

Return Value

Type: T*

The existing or created item or null if no item was found or created.

Out: if the item existed then the pointer is not null

Meta