8// NewVersionedMap creates a new versioned, thread-safe map.
9func NewVersionedMap[K comparable, V any]() *VersionedMap[K, V] {
10 return &VersionedMap[K, V]{
15// VersionedMap is a thread-safe map that keeps track of its version.
16type VersionedMap[K comparable, V any] struct {
21// Get gets the value for the specified key from the map.
22func (m *VersionedMap[K, V]) Get(key K) (V, bool) {
26// Set sets the value for the specified key in the map and increments the version.
27func (m *VersionedMap[K, V]) Set(key K, value V) {
32// Del deletes the specified key from the map and increments the version.
33func (m *VersionedMap[K, V]) Del(key K) {
38// Seq2 returns an iter.Seq2 that yields key-value pairs from the map.
39func (m *VersionedMap[K, V]) Seq2() iter.Seq2[K, V] {
43// Len returns the number of items in the map.
44func (m *VersionedMap[K, V]) Len() int {
48// Version returns the current version of the map.
49func (m *VersionedMap[K, V]) Version() uint64 {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list