From 2a57d6783c147cf4dd8be9f1594744a176e5300a Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 13 Dec 2019 16:35:11 -1000 Subject: [PATCH] Export MapIterator --- go/types/map.go | 10 +++++----- go/types/map_iterator.go | 18 +++++++++--------- go/types/map_iterator_test.go | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go/types/map.go b/go/types/map.go index b41b69a532..01603fe8ba 100644 --- a/go/types/map.go +++ b/go/types/map.go @@ -202,18 +202,18 @@ func (m Map) Any(cb func(k, v Value) bool) (yep bool) { return } -func (m Map) Iterator() *mapIterator { +func (m Map) Iterator() *MapIterator { return m.IteratorAt(0) } -func (m Map) IteratorAt(pos uint64) *mapIterator { - return &mapIterator{ +func (m Map) IteratorAt(pos uint64) *MapIterator { + return &MapIterator{ cursor: newCursorAtIndex(m.orderedSequence, pos), } } -func (m Map) IteratorFrom(key Value) *mapIterator { - return &mapIterator{ +func (m Map) IteratorFrom(key Value) *MapIterator { + return &MapIterator{ cursor: newCursorAtValue(m.orderedSequence, key, false, false), } } diff --git a/go/types/map_iterator.go b/go/types/map_iterator.go index 7441984144..57e8a3d535 100644 --- a/go/types/map_iterator.go +++ b/go/types/map_iterator.go @@ -4,36 +4,36 @@ package types -// mapIterator can efficiently iterate through a Noms Map. -type mapIterator struct { +// MapIterator can efficiently iterate through a Noms Map. +type MapIterator struct { cursor *sequenceCursor currentKey Value currentValue Value } -func (mi *mapIterator) Valid() bool { +func (mi *MapIterator) Valid() bool { return mi.cursor.valid() } -func (mi *mapIterator) Entry() (k Value, v Value) { +func (mi *MapIterator) Entry() (k Value, v Value) { return mi.Key(), mi.Value() } -func (mi *mapIterator) Key() Value { +func (mi *MapIterator) Key() Value { if !mi.cursor.valid() { return nil } return mi.cursor.current().(mapEntry).key } -func (mi *mapIterator) Value() Value { +func (mi *MapIterator) Value() Value { if !mi.cursor.valid() { return nil } return mi.cursor.current().(mapEntry).value } -func (mi *mapIterator) Position() uint64 { +func (mi *MapIterator) Position() uint64 { if !mi.cursor.valid() { return 0 } @@ -41,7 +41,7 @@ func (mi *mapIterator) Position() uint64 { } // Prev returns the previous entry from the Map. If there is no previous entry, Prev() returns nils. -func (mi *mapIterator) Prev() bool { +func (mi *MapIterator) Prev() bool { if !mi.cursor.valid() { return false } @@ -50,7 +50,7 @@ func (mi *mapIterator) Prev() bool { // Next returns the subsequent entries from the Map, starting with the entry at which the iterator // was created. If there are no more entries, Next() returns nils. -func (mi *mapIterator) Next() bool { +func (mi *MapIterator) Next() bool { if !mi.cursor.valid() { return false } diff --git a/go/types/map_iterator_test.go b/go/types/map_iterator_test.go index ff938b7d4c..cb4f98cdc8 100644 --- a/go/types/map_iterator_test.go +++ b/go/types/map_iterator_test.go @@ -54,7 +54,7 @@ func TestMapIterator(t *testing.T) { for i, t := range tc { lbl := fmt.Sprintf("test case %d", i) - var it *mapIterator + var it *MapIterator if t.iter { it = m.Iterator() } else if t.iterFrom != "" {