28 lines
492 B
Go
28 lines
492 B
Go
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
package models
|
|
|
|
type NSKeys struct {
|
|
m map[int64]*NSKey // keyId => *NSKey
|
|
}
|
|
|
|
func NewNSKeys() *NSKeys {
|
|
return &NSKeys{m: map[int64]*NSKey{}}
|
|
}
|
|
|
|
func (this *NSKeys) Add(key *NSKey) {
|
|
this.m[key.Id] = key
|
|
}
|
|
|
|
func (this *NSKeys) Remove(keyId int64) {
|
|
delete(this.m, keyId)
|
|
}
|
|
|
|
func (this *NSKeys) All() []*NSKey {
|
|
var result = []*NSKey{}
|
|
for _, k := range this.m {
|
|
result = append(result, k)
|
|
}
|
|
return result
|
|
}
|