You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
638 B
32 lines
638 B
package skiplist
|
|
|
|
type ListStore interface {
|
|
SaveElement(id int64, element *SkipListElement) error
|
|
DeleteElement(id int64) error
|
|
LoadElement(id int64) (*SkipListElement, error)
|
|
}
|
|
|
|
type MemStore struct {
|
|
m map[int64]*SkipListElement
|
|
}
|
|
|
|
func newMemStore() *MemStore {
|
|
return &MemStore{
|
|
m: make(map[int64]*SkipListElement),
|
|
}
|
|
}
|
|
|
|
func (m *MemStore) SaveElement(id int64, element *SkipListElement) error {
|
|
m.m[id] = element
|
|
return nil
|
|
}
|
|
|
|
func (m *MemStore) DeleteElement(id int64) error {
|
|
delete(m.m, id)
|
|
return nil
|
|
}
|
|
|
|
func (m *MemStore) LoadElement(id int64) (*SkipListElement, error) {
|
|
element := m.m[id]
|
|
return element, nil
|
|
}
|