Remove List.Map (#3726)

This commit is contained in:
Benjamin Kalman
2017-09-20 10:36:05 -07:00
committed by GitHub
parent 84fa19f2c7
commit 71164e1cd2
2 changed files with 0 additions and 32 deletions

View File

@@ -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.

View File

@@ -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))
}