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