-
Notifications
You must be signed in to change notification settings - Fork 178
/
identifier_map.go
32 lines (24 loc) · 1.08 KB
/
identifier_map.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package mempool
import (
"github.com/onflow/flow-go/model/flow"
)
// IdentifierMap represents a concurrency-safe memory pool for mapping an identifier to a list of identifiers
type IdentifierMap interface {
// Append will append the id to the list of identifiers associated with key.
Append(key, id flow.Identifier) error
// Rem removes the given key with all associated identifiers.
Rem(key flow.Identifier) bool
// RemIdFromKey removes the id from the list of identifiers associated with key.
// If the list becomes empty, it also removes the key from the map.
RemIdFromKey(key, id flow.Identifier) error
// Get returns list of all identifiers associated with key and true, if the key exists in the mempool.
// Otherwise it returns nil and false.
Get(key flow.Identifier) ([]flow.Identifier, bool)
// Has returns true if the key exists in the map, i.e., there is at least an id
// attached to it.
Has(key flow.Identifier) bool
// Keys returns a list of all keys in the mempool
Keys() ([]flow.Identifier, bool)
// Size returns number of IdMapEntities in mempool
Size() uint
}