From 71164e1cd2d49649c05af1c53d6faef2d9fe6b2c Mon Sep 17 00:00:00 2001 From: Benjamin Kalman Date: Wed, 20 Sep 2017 10:36:05 -0700 Subject: [PATCH] Remove List.Map (#3726) --- go/types/list.go | 19 ------------------- go/types/list_test.go | 13 ------------- 2 files changed, 32 deletions(-) diff --git a/go/types/list.go b/go/types/list.go index 779546067f..3abe5e0975 100644 --- a/go/types/list.go +++ b/go/types/list.go @@ -118,25 +118,6 @@ func (l List) Get(idx uint64) Value { return cur.current().(Value) } -type MapFunc func(v Value, index uint64) interface{} - -// Deprecated: This API may change in the future. Use IterAll or Iterator instead. -func (l List) Map(mf MapFunc) []interface{} { - // TODO: This is bad API. It should have returned another List. - // https://github.com/attic-labs/noms/issues/2557 - idx := uint64(0) - cur := newCursorAtIndex(l.seq, idx, true) - - results := make([]interface{}, 0, l.Len()) - cur.iter(func(v interface{}) bool { - res := mf(v.(Value), uint64(idx)) - results = append(results, res) - idx++ - return false - }) - return results -} - // Concat returns a new List comprised of this joined with other. It only needs // to visit the rightmost prolly tree chunks of this List, and the leftmost // prolly tree chunks of other, so it's efficient. diff --git a/go/types/list_test.go b/go/types/list_test.go index ec960aa479..2bf8675089 100644 --- a/go/types/list_test.go +++ b/go/types/list_test.go @@ -147,19 +147,6 @@ func (suite *listTestSuite) TestIter() { suite.Equal(endAt, expectIdx) } -func (suite *listTestSuite) TestMap() { - list := suite.col.(List) - l := list.Map(func(v Value, i uint64) interface{} { - v1 := v.(Number) - return v1 + Number(i) - }) - - suite.Equal(uint64(len(l)), suite.expectLen) - for i := 0; i < len(l); i++ { - suite.Equal(l[i], list.Get(uint64(i)).(Number)+Number(i)) - } -} - func TestListSuite4K(t *testing.T) { suite.Run(t, newListTestSuite(12, 9, 2, 2)) }