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

  1. package skiplist
  2. type ListStore interface {
  3. SaveElement(id int64, element *SkipListElement) error
  4. DeleteElement(id int64) error
  5. LoadElement(id int64) (*SkipListElement, error)
  6. }
  7. type MemStore struct {
  8. m map[int64]*SkipListElement
  9. }
  10. func newMemStore() *MemStore {
  11. return &MemStore{
  12. m: make(map[int64]*SkipListElement),
  13. }
  14. }
  15. func (m *MemStore) SaveElement(id int64, element *SkipListElement) error {
  16. m.m[id] = element
  17. return nil
  18. }
  19. func (m *MemStore) DeleteElement(id int64) error {
  20. delete(m.m, id)
  21. return nil
  22. }
  23. func (m *MemStore) LoadElement(id int64) (*SkipListElement, error) {
  24. element := m.m[id]
  25. return element, nil
  26. }