Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/treemap/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ func (m *TreeMap[K, V]) LowerBound(key K) *TreeMapIterator[K, V] {
return &TreeMapIterator[K, V]{iter}
}

// FoorOrMin finds the floor key-value pair for the input key.
// FloorOrMin finds the floor key-value pair for the input key.
// If no floor is found, returns the key-value pair for the least key.
// In case that map is empty, then both returned values will be corresponding type's empty value.
//
// Floor key is defined as the greatest key that is less than or equal to the given key.
// A floor key may not be found, either because the map is empty, or because
// all keys in the map are greater than the given key.
func (m *TreeMap[K, V]) FoorOrMin(key K) (foundKey K, foundValue V, ok bool) {
func (m *TreeMap[K, V]) FloorOrMin(key K) (foundKey K, foundValue V, ok bool) {
node, found := m.tree.Floor(key)
if found {
return node.Key, node.Value, true
Expand Down
4 changes: 2 additions & 2 deletions pkg/treemap/treemap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestMapLowerBound(t *testing.T) {
}
}

func TestMapFoorOrMin(t *testing.T) {
func TestMapFloorOrMin(t *testing.T) {
m := New[int, string]()
m.Put(1, "a")
m.Put(3, "c")
Expand All @@ -326,7 +326,7 @@ func TestMapFoorOrMin(t *testing.T) {

for _, test := range tests1 {
// retrievals
actualKey, actualValue, ok := m.FoorOrMin(test.boundKey)
actualKey, actualValue, ok := m.FloorOrMin(test.boundKey)
if actualKey != test.Key || actualValue != test.Value || ok != test.Exist {
t.Errorf("Got %v, %v, %v, expected %v, %v, %v", actualKey, actualValue, ok, test.Key, test.Value, test.Exist)
}
Expand Down