-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
33 lines (29 loc) · 1.05 KB
/
types.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
33
package container
type OrderedMap[K comparable, V any] interface {
Delete(key K)
Load(key K) (value V, loaded bool)
Range(func(key K, value V) bool)
Store(key K, value V)
}
// Queue is generic queue with no concurrency guarantees.
// Instantiate by queue.New<implementation>Queue(sizeHint).
// The size hint MAY be used by some implementations to optimize storage.
type Queue[E any] interface {
Enqueue(E)
// Dequeue removes the first element from the queue. If the queue is empty,
// it returns the zero value of the element type, and ok is false.
Dequeue() (e E, ok bool)
}
// Stack is a generic queue with no concurrency guarantees.
// Instantiate by stack.New<implementation>Stack(sizeHint).
// The size hint MAY be used by some implementations to optimize storage.
type Stack[E any] interface {
Push(E)
// Pop removes the top element from the stack. If the stack is empty,
// it returns the zero value of the element type, and ok is false.
Pop() (e E, ok bool)
}
// Countable MAY be provided by some implementations.
type Countable interface {
Len() int
}