1234567891011121314151617181920212223242526272829303132 |
- 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
- }
|