Skip to content

Commit

Permalink
rename, publish MemoryIter
Browse files Browse the repository at this point in the history
  • Loading branch information
annybs committed Jul 8, 2024
1 parent a3d8644 commit 43c486b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions leveldb_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (i *LevelDBIterator[T]) Filter(f FilterFunc[T]) Iterator[T] {
m[key] = value
}

return newMemoryIterator(m, nil, i)
return MemoryIter(m, nil, i)
}

func (i *LevelDBIterator[T]) First() bool {
Expand Down Expand Up @@ -109,13 +109,13 @@ func (i *LevelDBIterator[T]) Release() {

func (i *LevelDBIterator[T]) Sort(f SortFunc[T]) Iterator[T] {
all, _ := i.GetAll()
m := newMemoryIterator(all, nil, i)
m := MemoryIter(all, nil, i)
return m.Sort(f)
}

func (i *LevelDBIterator[T]) SortKeys(f SortFunc[string]) Iterator[T] {
all, _ := i.GetAll()
m := newMemoryIterator(all, nil, i)
m := MemoryIter(all, nil, i)
return m.SortKeys(f)
}

Expand Down
2 changes: 1 addition & 1 deletion memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *MemoryCollection[T]) Has(key string) (bool, error) {
}

func (c *MemoryCollection[T]) Iter() Iterator[T] {
m := newMemoryIterator[T](c.m, nil, nil)
m := MemoryIter[T](c.m, nil, nil)
if !c.open {
m.Release()
}
Expand Down
8 changes: 4 additions & 4 deletions memory_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (i *MemoryIterator[T]) Filter(f FilterFunc[T]) Iterator[T] {
m[key] = value
}
}
return newMemoryIterator(m, k, i)
return MemoryIter(m, k, i)
}

func (i *MemoryIterator[T]) First() bool {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (i *MemoryIterator[T]) Sort(f SortFunc[T]) Iterator[T] {
sort.Stable(s)
k := s.Result()

return newMemoryIterator(i.m, k, i)
return MemoryIter(i.m, k, i)
}

func (i *MemoryIterator[T]) SortKeys(f SortFunc[string]) Iterator[T] {
Expand All @@ -154,7 +154,7 @@ func (i *MemoryIterator[T]) SortKeys(f SortFunc[string]) Iterator[T] {
sort.Stable(s)
k := s.Result()

return newMemoryIterator(i.m, k, i)
return MemoryIter(i.m, k, i)
}

func (i *MemoryIterator[T]) Value() (T, error) {
Expand All @@ -166,7 +166,7 @@ func (i *MemoryIterator[T]) reset() {
i.pos = -1
}

func newMemoryIterator[T any](m map[string]T, k []string, prev Iterator[T]) *MemoryIterator[T] {
func MemoryIter[T any](m map[string]T, k []string, prev Iterator[T]) *MemoryIterator[T] {
i := &MemoryIterator[T]{
k: []string{},
m: m,
Expand Down

0 comments on commit 43c486b

Please sign in to comment.