iterator.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //@File iterator.go
  2. //@Time 2022/05/12
  3. //@Author #Suyghur,
  4. package iterator
  5. type ConstIterator interface {
  6. IsValid() bool
  7. Next() ConstIterator
  8. Value() interface{}
  9. Clone() ConstIterator
  10. Equal(other ConstIterator) bool
  11. }
  12. // Iterator is an interface of mutable iterator
  13. type Iterator interface {
  14. ConstIterator
  15. SetValue(value interface{})
  16. }
  17. // ConstKvIterator is an interface of const key-value type iterator
  18. type ConstKvIterator interface {
  19. ConstIterator
  20. Key() interface{}
  21. }
  22. // KvIterator is an interface of mutable key-value type iterator
  23. type KvIterator interface {
  24. ConstKvIterator
  25. SetValue(value interface{})
  26. }
  27. // ConstBidIterator is an interface of const bidirectional iterator
  28. type ConstBidIterator interface {
  29. ConstIterator
  30. Prev() ConstBidIterator
  31. }
  32. // BidIterator is an interface of mutable bidirectional iterator
  33. type BidIterator interface {
  34. ConstBidIterator
  35. SetValue(value interface{})
  36. }
  37. // ConstKvBidIterator is an interface of const key-value type bidirectional iterator
  38. type ConstKvBidIterator interface {
  39. ConstKvIterator
  40. Prev() ConstBidIterator
  41. }
  42. // KvBidIterator is an interface of mutable key-value type bidirectional iterator
  43. type KvBidIterator interface {
  44. ConstKvIterator
  45. Prev() ConstBidIterator
  46. SetValue(value interface{})
  47. }
  48. // RandomAccessIterator is an interface of mutable random access iterator
  49. type RandomAccessIterator interface {
  50. BidIterator
  51. //IteratorAt returns a new iterator at position
  52. IteratorAt(position int) RandomAccessIterator
  53. Position() int
  54. }