Atlas › Test

take_present

Exact test identity: go.temporal.io/server/common/collection/TestIndexedTakeList/take_present

Package
go.temporal.io/server/common/collection
Suite / test hierarchy
TestIndexedTakeList/take_present
Test
take_present
Introduced at
take_present Frontier kind: Test frontier
Covered ranges
8
Covered lines
17
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/collection/indexedtakelist.go 17 covered LOC · 8 ranges

Open complete file

21 values []V,
22 indexer func(V) K,
23 > ) *IndexedTakeList[K, V] { indexedtakelist.go
24 > ret := &IndexedTakeList[K, V]{
25 > values: make([]kv[K, V], 0, len(values)),
26 > }
27 > for _, v := range values {
28 > ret.values = append(ret.values, kv[K, V]{key: indexer(v), value: v}) indexedtakelist.go
29 > }
30 > return ret indexedtakelist.go
31 }
32
33 // Take finds a value in this set by its key and removes it, returning the
34 // value.
35 > func (itl *IndexedTakeList[K, V]) Take(key K) (V, bool) { indexedtakelist.go
36 > var zero V
37 > for i := 0; i < len(itl.values); i++ {
38 > kv := &itl.values[i] indexedtakelist.go
39 > if kv.key != key {
40 > continue indexedtakelist.go
41 }
42 > if kv.removed { indexedtakelist.go
43 return zero, false
44 }
45 > kv.removed = true indexedtakelist.go
46 > return kv.value, true
47 }
48 return zero, false