feat: add GetUInt and PutUInt

This commit is contained in:
Derrick Hammer 2024-01-15 12:56:40 -05:00
parent def05376f5
commit 6e2b08dd05
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 22 additions and 0 deletions

View File

@ -11,8 +11,10 @@ var _ maps.Map = (*MapImpl)(nil)
type Map interface { type Map interface {
GetInt(key interface{}) (value *int) GetInt(key interface{}) (value *int)
GetUInt(key interface{}) (value *uint)
GetString(key interface{}) (value *string) GetString(key interface{}) (value *string)
PutInt(key interface{}, value int) PutInt(key interface{}, value int)
PutUInt(key interface{}, value uint)
Contains(value interface{}) bool Contains(value interface{}) bool
maps.Map maps.Map
} }
@ -51,6 +53,22 @@ func (m *MapImpl) GetInt(key interface{}) (value *int) {
return value return value
} }
func (m *MapImpl) GetUInt(key interface{}) (value *uint) {
val, found := m.Get(key)
if !found {
return nil
}
if intValue, ok := val.(uint); ok {
value = &intValue
} else {
log.Fatalf("value is not an uint: %v", val)
}
return value
}
func (m *MapImpl) GetString(key interface{}) (value *string) { func (m *MapImpl) GetString(key interface{}) (value *string) {
val, found := m.Get(key) val, found := m.Get(key)
@ -77,6 +95,10 @@ func (m *MapImpl) PutInt(key interface{}, value int) {
m.Put(key, value) m.Put(key, value)
} }
func (m *MapImpl) PutUInt(key interface{}, value uint) {
m.Put(key, value)
}
func (m *MapImpl) Remove(key interface{}) { func (m *MapImpl) Remove(key interface{}) {
m.mutex.Lock() m.mutex.Lock()
defer m.mutex.Unlock() defer m.mutex.Unlock()