qrz/vendor/github.com/gobuffalo/packr/v2/box_map.go
Paul Lecuq 36c5d6f2ed
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
large change on qrz
- web service with json support
- web page
- cron service to update database infos
2020-05-09 19:09:27 +02:00

74 lines
1.6 KiB
Go

//go:generate mapgen -name "box" -zero "nil" -go-type "*Box" -pkg "" -a "New(`test-a`, ``)" -b "New(`test-b`, ``)" -c "New(`test-c`, ``)" -bb "New(`test-bb`, ``)" -destination "packr"
// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT.
package packr
import (
"sort"
"sync"
)
// boxMap wraps sync.Map and uses the following types:
// key: string
// value: *Box
type boxMap struct {
data sync.Map
}
// Delete the key from the map
func (m *boxMap) Delete(key string) {
m.data.Delete(key)
}
// Load the key from the map.
// Returns *Box or bool.
// A false return indicates either the key was not found
// or the value is not of type *Box
func (m *boxMap) Load(key string) (*Box, bool) {
i, ok := m.data.Load(key)
if !ok {
return nil, false
}
s, ok := i.(*Box)
return s, ok
}
// LoadOrStore will return an existing key or
// store the value if not already in the map
func (m *boxMap) LoadOrStore(key string, value *Box) (*Box, bool) {
i, _ := m.data.LoadOrStore(key, value)
s, ok := i.(*Box)
return s, ok
}
// Range over the *Box values in the map
func (m *boxMap) Range(f func(key string, value *Box) bool) {
m.data.Range(func(k, v interface{}) bool {
key, ok := k.(string)
if !ok {
return false
}
value, ok := v.(*Box)
if !ok {
return false
}
return f(key, value)
})
}
// Store a *Box in the map
func (m *boxMap) Store(key string, value *Box) {
m.data.Store(key, value)
}
// Keys returns a list of keys in the map
func (m *boxMap) Keys() []string {
var keys []string
m.Range(func(key string, value *Box) bool {
keys = append(keys, key)
return true
})
sort.Strings(keys)
return keys
}