v0.0.644 exerr.DeregisterListener
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m18s
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m18s
This commit is contained in:
+27
-4
@@ -6,15 +6,28 @@ import (
|
||||
)
|
||||
|
||||
// OrderedMap is like a normal map[TKey, TVal] - but its elements stay in order
|
||||
// NOT THREADSAFE !!!
|
||||
type OrderedMap[TKey comparable, TVal any] struct {
|
||||
m map[TKey]*TVal
|
||||
a []TKey
|
||||
}
|
||||
|
||||
func NewOrderedMap[TKey comparable, TVal any](cap int) *OrderedMap[TKey, TVal] {
|
||||
func NewOrderedMap[TKey comparable, TVal any](caps ...int) *OrderedMap[TKey, TVal] {
|
||||
if len(caps) == 0 {
|
||||
return &OrderedMap[TKey, TVal]{
|
||||
m: make(map[TKey]*TVal),
|
||||
a: make([]TKey, 0),
|
||||
}
|
||||
}
|
||||
|
||||
omcap := 0
|
||||
for _, v := range caps {
|
||||
omcap += v
|
||||
}
|
||||
|
||||
return &OrderedMap[TKey, TVal]{
|
||||
m: make(map[TKey]*TVal, cap),
|
||||
a: make([]TKey, 0, cap),
|
||||
m: make(map[TKey]*TVal, omcap),
|
||||
a: make([]TKey, 0, omcap),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +98,17 @@ func (o *OrderedMap[TKey, TVal]) Remove(key TKey) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (o *OrderedMap[TKey, TVal]) Iterate() iter.Seq[TVal] {
|
||||
func (o *OrderedMap[TKey, TVal]) Iterate() iter.Seq2[TKey, TVal] {
|
||||
return func(yield func(TKey, TVal) bool) {
|
||||
for _, v := range o.a {
|
||||
if !yield(v, *o.m[v]) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o *OrderedMap[TKey, TVal]) IterateValues() iter.Seq[TVal] {
|
||||
return func(yield func(TVal) bool) {
|
||||
for _, v := range o.a {
|
||||
if !yield(*o.m[v]) {
|
||||
|
||||
Reference in New Issue
Block a user