Commits

Stepan Koltsov committed 75a1fea

rename ListMap -> Tuple2List

Comments (0)

Files changed (12)

src/main/java/ru/yandex/bolts/collection/CollectionsF.java

 
     /** Create map from sequence of entries */
     public static <K, V> MapF<K, V> map(Collection<Tuple2<K, V>> pairs) {
-        return ListMap.listMap(Cf.x(pairs).toList()).toMap();
+        return Tuple2List.tuple2List(Cf.x(pairs).toList()).toMap();
     }
 
     /**

src/main/java/ru/yandex/bolts/collection/CollectionsFTest.java

 package ru.yandex.bolts.collection;
 
-import java.util.Collection;
-
 import junit.framework.TestCase;
 
 import ru.yandex.bolts.function.Function;
     }
 
     public void testMapFandSortFandUniqueF() {
-        ListMap<String, Integer> data = ListMap.<String, Integer>listMap()
+        Tuple2List<String, Integer> data = Tuple2List.<String, Integer>tuple2List()
                 .plus1("foo", 102)
                 .plus1("bar", 98)
                 .plus1("baz", 98)

src/main/java/ru/yandex/bolts/collection/ListF.java

 package ru.yandex.bolts.collection;
 
-import java.util.List;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 
 import ru.yandex.bolts.function.Function;
 import ru.yandex.bolts.function.Function1B;
     /**
      * Zip with index.
      */
-    ListMap<E, Integer> zipWithIndex();
+    Tuple2List<E, Integer> zipWithIndex();
 
     /** Concatenate two lists */
     ListF<E> plus(List<? extends E> addition);
     <F> ListF<F> uncheckedCast();
 
     /** List of pairs of elements with the same index in two lists */
-    <B> ListMap<E, B> zip(ListF<B> that);
+    <B> Tuple2List<E, B> zip(ListF<B> that);
 
-    <B> ListMap<E, B> zipWith(Function<? super E, ? extends B> f);
+    <B> Tuple2List<E, B> zipWith(Function<? super E, ? extends B> f);
 
-    <B> ListMap<E, B> zipWithW(@FunctionParameter B f);
+    <B> Tuple2List<E, B> zipWithW(@FunctionParameter B f);
 } //~

src/main/java/ru/yandex/bolts/collection/ListMap.java

 import java.util.Iterator;
 import java.util.List;
 
-import ru.yandex.bolts.collection.impl.DefaultListF;
-import ru.yandex.bolts.function.*;
+import ru.yandex.bolts.function.Function;
+import ru.yandex.bolts.function.Function1B;
+import ru.yandex.bolts.function.Function2;
+import ru.yandex.bolts.function.Function2B;
+import ru.yandex.bolts.function.Function2I;
+import ru.yandex.bolts.function.Function2V;
 import ru.yandex.bolts.function.forhuman.Comparator;
 
 /**
  *
  * @author Stepan Koltsov
  * @author Iliya Roubin
+ *
+ * @deprecated
+ * @see Tuple2List
  */
-public class ListMap<K, V> extends DefaultListF<Tuple2<K,V>> {
+public class ListMap<K, V> extends Tuple2List<K, V> {
     private ListMap(List<Tuple2<K, V>> list) {
         super(list);
     }
         return partitionLm(Tuple2.<K, V>get2F().andThen(p));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> subList(int fromIndex, int toIndex) {
         return ListMap.listMap(super.subList(fromIndex, toIndex));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> plus(List<? extends Tuple2<K, V>> addition) {
         return ListMap.listMap(super.plus(addition));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> plus(Collection<? extends Tuple2<K, V>> elements) {
         return ListMap.listMap(super.plus(elements));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> plus(Iterator<? extends Tuple2<K, V>> iterator) {
         return ListMap.listMap(super.plus(iterator));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> plus(Tuple2<K, V>... additions) {
         return ListMap.listMap(super.plus(additions));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> take(int count) {
         return ListMap.listMap(super.take(count));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> drop(int count) {
         return ListMap.listMap(super.drop(count));
         return ListMap.listMap();
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> reverse() {
         return ListMap.listMap(super.reverse());
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> sort(Function2I<? super Tuple2<K, V>, ? super Tuple2<K, V>> comparator) {
         return ListMap.listMap(super.sort(comparator));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> sortBy(Function<? super Tuple2<K, V>, ?> f) {
         return ListMap.listMap(super.sortBy(f));
     }
 
-    @SuppressWarnings({"unchecked"})
     @Override
     public ListMap<K, V> sortByDesc(Function<? super Tuple2<K, V>, ?> f) {
         return ListMap.listMap(super.sortByDesc(f));

src/main/java/ru/yandex/bolts/collection/ListMapTest.java

-package ru.yandex.bolts.collection;
-
-import junit.framework.TestCase;
-
-import ru.yandex.bolts.function.Function1B;
-
-/**
- * @author Stepan Koltsov
- * @author Iliya Roubin
- */
-public class ListMapTest extends TestCase {
-
-    public void testFlatMapFromPairs() {
-        assertEquals(ListMap.listMap(), ListMap.listMapFromPairs());
-
-        ListMap<String, Integer> fm = ListMap.listMapFromPairs("a", 1, "b", 2);
-        assertEquals(2, fm.length());
-        assertEquals(Tuple2.tuple("a", 1), fm.get(0));
-        assertEquals(Tuple2.tuple("b", 2), fm.get(1));
-    }
-
-    public void testSortByKey() {
-        assertEquals(ListMap.listMapFromPairs("a", 2, "a", 1, "b", 4), ListMap.listMapFromPairs("b", 4, "a", 2, "a", 1).sortByKey());
-    }
-
-    public void testPlus() {
-        ListMap<String, Integer> lm = ListMap.listMapFromPairs("a", 1, "b", 2);
-        assertSame(lm, lm.plus(ListMap.<String, Integer>arrayList()));
-        assertSame(lm, ListMap.<String, Integer>arrayList().plus(lm));
-
-        assertEquals(ListMap.listMapFromPairs("a", 1, "b", 2, "c", 3), ListMap.listMapFromPairs("a", 1, "b", 2).plus(ListMap.listMapFromPairs("c", 3)));
-        assertEquals(ListMap.<String, Integer>listMapFromPairs("a", 1, "b", 2, "c", 3),
-                ListMap.<String, Integer>listMapFromPairs("a", 1, "b", 2).plus(Tuple2.tuple("c", 3)));
-    }
-
-    public void testFilter() {
-        ListMap<String, Integer> lm = ListMap.listMapFromPairs("a", 1, "b", 2);
-        ListMap<String, Integer> lmf = lm.filter(new Function1B<Tuple2<String, Integer>>() {
-            @Override
-            public boolean apply(Tuple2<String, Integer> t) {
-                return "a".equals(t.get1());
-            }
-        });
-        assertEquals(ListMap.<String, Integer>listMapFromPairs("a", 1), lmf);
-    }
-
-    public void testPartitionLm() {
-        ListMap<String, Integer> lm = ListMap.listMapFromPairs("a", 1, "b", 2);
-        Tuple2<ListMap<String, Integer>, ListMap<String, Integer>> t = lm.partitionLm(new Function1B<Tuple2<String, Integer>>() {
-            @Override
-            public boolean apply(Tuple2<String, Integer> t) {
-                return "a".equals(t.get1());
-            }
-        });
-        assertEquals(ListMap.<String, Integer>listMapFromPairs("a", 1), t.get1());
-        assertEquals(ListMap.<String, Integer>listMapFromPairs("b", 2), t.get2());
-    }
-
-    public void testTakeDrop() {
-        ListMap<String, Integer> lm = ListMap.listMapFromPairs("a", 1, "b", 2);
-        assertEquals(ListMap.<String, Integer>listMapFromPairs("a", 1), lm.take(1));
-        assertEquals(ListMap.<String, Integer>listMapFromPairs("b", 2), lm.drop(1));
-    }
-
-    public void testReverse() {
-        assertEquals(ListMap.listMapFromPairs("a", 1, "b", 2),
-                ListMap.listMapFromPairs("b", 2, "a", 1).reverse());
-    }
-
-    public void testMapPlusToArray() {
-        assertEquals(1, ListMap.listMapFromPairs("a", 1).map(Tuple2.get2F()).plus(Cf.list(2)).toArray()[0]);
-        assertEquals(1, ListMap.listMap().map(Tuple2.get2F()).plus(Cf.list(1)).toArray()[0]);
-    }
-} //~

src/main/java/ru/yandex/bolts/collection/MapF.java

 
     SetF<Entry<K, V>> entrySet();
 
-    ListMap<K, V> entries();
+    Tuple2List<K, V> entries();
 
     /** Values */
     CollectionF<V> values();

src/main/java/ru/yandex/bolts/collection/Tuple2List.java

+package ru.yandex.bolts.collection;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import ru.yandex.bolts.collection.impl.DefaultListF;
+import ru.yandex.bolts.function.Function;
+import ru.yandex.bolts.function.Function1B;
+import ru.yandex.bolts.function.Function2;
+import ru.yandex.bolts.function.Function2B;
+import ru.yandex.bolts.function.Function2I;
+import ru.yandex.bolts.function.Function2V;
+import ru.yandex.bolts.function.forhuman.Comparator;
+
+/**
+ * @author Stepan Koltsov
+ */
+@SuppressWarnings("serial")
+public class Tuple2List<K, V> extends DefaultListF<Tuple2<K, V>> {
+
+    private Tuple2List(List<Tuple2<K, V>> list) {
+        super(list);
+    }
+
+    public Tuple2List(Collection<Tuple2<K, V>> elements) {
+        super(new ArrayList<Tuple2<K, V>>(elements));
+    }
+
+    @SuppressWarnings({"unchecked"})
+    @Override
+    protected Tuple2List<K, V> newMutableCollection() {
+        return Tuple2List.arrayList();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Tuple2List<K, V> filter(Function1B<? super Tuple2<K, V>> p) {
+        return (Tuple2List<K, V>) super.filter(p);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Tuple2<Tuple2List<K, V>, Tuple2List<K, V>> partitionT2l(Function1B<? super Tuple2<K, V>> p) {
+        return (Tuple2) super.partition(p);
+    }
+
+    public Tuple2<Tuple2List<K, V>, Tuple2List<K, V>> partitionBy1(Function1B<? super K> p) {
+        return partitionT2l(Tuple2.<K, V>get1F().andThen(p));
+    }
+
+    public Tuple2<Tuple2List<K, V>, Tuple2List<K, V>> partitionBy2(Function1B<? super V> p) {
+        return partitionT2l(Tuple2.<K, V>get2F().andThen(p));
+    }
+
+    @Override
+    public Tuple2List<K, V> subList(int fromIndex, int toIndex) {
+        return Tuple2List.tuple2List(super.subList(fromIndex, toIndex));
+    }
+
+    @Override
+    public Tuple2List<K, V> plus(List<? extends Tuple2<K, V>> addition) {
+        return Tuple2List.tuple2List(super.plus(addition));
+    }
+
+    @Override
+    public Tuple2List<K, V> plus(Collection<? extends Tuple2<K, V>> elements) {
+        return Tuple2List.tuple2List(super.plus(elements));
+    }
+
+    @Override
+    public Tuple2List<K, V> plus(Iterator<? extends Tuple2<K, V>> iterator) {
+        return Tuple2List.tuple2List(super.plus(iterator));
+    }
+
+    @Override
+    public Tuple2List<K, V> plus(Tuple2<K, V>... additions) {
+        return Tuple2List.tuple2List(super.plus(additions));
+    }
+
+    @Override
+    public Tuple2List<K, V> take(int count) {
+        return Tuple2List.tuple2List(super.take(count));
+    }
+
+    @Override
+    public Tuple2List<K, V> drop(int count) {
+        return Tuple2List.tuple2List(super.drop(count));
+    }
+
+    @Override
+    protected Tuple2List<K, V> emptyList() {
+        return Tuple2List.tuple2List();
+    }
+
+    @Override
+    public Tuple2List<K, V> reverse() {
+        return Tuple2List.tuple2List(super.reverse());
+    }
+
+    @Override
+    public Tuple2List<K, V> sort(Function2I<? super Tuple2<K, V>, ? super Tuple2<K, V>> comparator) {
+        return Tuple2List.tuple2List(super.sort(comparator));
+    }
+
+    @Override
+    public Tuple2List<K, V> sortBy(Function<? super Tuple2<K, V>, ?> f) {
+        return Tuple2List.tuple2List(super.sortBy(f));
+    }
+
+    @Override
+    public Tuple2List<K, V> sortByDesc(Function<? super Tuple2<K, V>, ?> f) {
+        return Tuple2List.tuple2List(super.sortByDesc(f));
+    }
+
+    public <U> Tuple2List<U, V> map1(final Function<K, U> mapper) {
+        Function<Tuple2<K, V>, Tuple2<U, V>> m2 = new Function<Tuple2<K, V>, Tuple2<U, V>>() {
+            public Tuple2<U, V> apply(Tuple2<K, V> a) {
+                return Tuple2.tuple(mapper.apply(a.get1()), a.get2());
+            }
+        };
+
+        Tuple2List<U, V> r = Tuple2List.arrayList();
+        this.iterator().map(m2).forEach(r.addOp());
+        return r;
+    }
+
+    public <U> Tuple2List<K, U> map2(final Function<V, U> mapper) {
+        Function<Tuple2<K, V>, Tuple2<K, U>> m2 = new Function<Tuple2<K, V>, Tuple2<K, U>>() {
+            public Tuple2<K, U> apply(Tuple2<K, V> a) {
+                return Tuple2.tuple(a.get1(), mapper.apply(a.get2()));
+            }
+        };
+
+        Tuple2List<K, U> r = Tuple2List.arrayList();
+        this.iterator().map(m2).forEach(r.addOp());
+        return r;
+    }
+
+    public Tuple2List<K, V> filter2(Function1B<? super V> p) {
+        return new Tuple2List<K, V>(filter(get2F().andThen(p)));
+    }
+
+    public Tuple2List<K, V> filter1(Function1B<? super K> p) {
+        return new Tuple2List<K, V>(filter(get1F().andThen(p)));
+    }
+
+    public Option<Tuple2<K, V>> findBy1(Function1B<? super K> p) {
+        return find(get1F().andThen(p));
+    }
+
+    public void put(K k, V v) {
+        add(Tuple2.tuple(k, v));
+    }
+
+    public Function2V<K, V> putOp() {
+        return new Function2V<K, V>() {
+            public void apply(K a, V b) {
+                put(a, b);
+            }
+        };
+    }
+
+    public void put(Tuple2<? extends K, ? extends V> tuple) {
+        super.add(tuple.<K, V>uncheckedCast());
+    }
+
+    @Override
+    public Tuple2List<K, V> plus1(Tuple2<K, V> e) {
+        return new Tuple2List<K, V>(Cf.x(target).plus1(e));
+    }
+
+    public Tuple2List<K, V> plus1(K key, V value) {
+        return plus1(Tuple2.tuple(key, value));
+    }
+
+    private Function<Tuple2<K, V>, K> get1F() {
+        return Tuple2.get1F();
+    }
+
+    private Function<Tuple2<K, V>, V> get2F() {
+        return Tuple2.get2F();
+    }
+
+    public ListF<K> get1() {
+        return map(get1F());
+    }
+
+    public ListF<V> get2() {
+        return map(get2F());
+    }
+
+    public Tuple2List<V, K> invert() {
+        return tuple2List(map(Tuple2.<K, V>swapF()));
+    }
+
+    /**
+     * @see CollectionF#sort()
+     */
+    public Tuple2List<K, V> sortBy1() {
+        return sortBy1(Comparator.naturalComparator().<K, K>uncheckedCast());
+    }
+
+    /**
+     * @see CollectionF#sort(Function2I)
+     */
+    @SuppressWarnings("unchecked")
+    public Tuple2List<K, V> sortBy1(Function2I<? super K, ? super K> comparator) {
+        if (size() <= 1) return this;
+        return new Tuple2List<K, V>(sort(get1F().andThen((Function2I<K, K>) comparator)));
+    }
+
+    // XXX: sortByKeyBy, sortByKeyByDesc
+
+    public MapF<K, V> toMap() {
+        if (isEmpty()) return Cf.map();
+        else return Cf.hashMap(this);
+    }
+
+    @SuppressWarnings({"unchecked", "ToArrayCallWithZeroLengthArrayArgument"})
+    @Override
+    public Tuple2<K, V>[] toArray() {
+        return toArray(new Tuple2[0]);
+    }
+
+    public Tuple2List<K, V> unmodifiable() {
+        return new Tuple2List<K, V>(Cf.x(target).unmodifiable());
+    }
+
+    /**
+     * @see #uncheckedCast()
+     */
+    @SuppressWarnings("unchecked")
+    public <F, G> Tuple2List<F, G> uncheckedCastT2l() {
+        return (Tuple2List<F, G>) this;
+    }
+
+    public <W> ListF<W> map(Function2<? super K, ? super V, ? extends W> mapper) {
+        return map(mapper.<K, V, W>uncheckedCast().asFunction());
+    }
+
+    public void forEach(Function2V<K, V> f) {
+        super.forEach(f.asFunction1V());
+    }
+
+    public boolean forAll(Function2B<K, V> f) {
+        return super.forAll(f.asTupleFunction());
+    }
+
+    public String mkString(String elemSep, final String tupleSep) {
+        return map(new Function2<K, V, String>() {
+            public String apply(K a, V b) {
+                return a + tupleSep + b;
+            }
+        }).mkString(elemSep);
+    }
+
+    public Tuple2List<K, V> plus(Tuple2List<K, V> that) {
+        if (that.isEmpty()) return this;
+        else if (this.isEmpty()) return that;
+        else return new Tuple2List<K, V>(super.plus(that.target));
+    }
+
+    /**
+     * Unchecked.
+     */
+    @SuppressWarnings("unchecked")
+    public static <A, B> Tuple2List<A, B> fromPairs(Object... elements) {
+        if (elements.length % 2 != 0)
+            throw new IllegalArgumentException();
+        if (elements.length == 0)
+            return tuple2List();
+        Tuple2<A, B>[] es = new Tuple2[elements.length / 2];
+        for (int i = 0; i < es.length; ++i) {
+            es[i] = Tuple2.tuple((A) elements[i * 2], (B) elements[i * 2 + 1]);
+        }
+        return tuple2List(es);
+    }
+
+    /**
+     * @see ListF#zip(ListF)
+     */
+    public static <A, B> Tuple2List<A, B> zip(ListF<A> list1, ListF<B> list2) {
+        Tuple2List<A, B> r = Tuple2List.arrayList();
+
+        IteratorF<A> ki = list1.iterator();
+        IteratorF<B> vi = list2.iterator();
+        while (ki.hasNext() && vi.hasNext()) {
+            r.put(ki.next(), vi.next());
+        }
+
+        return r;
+    }
+
+    /**
+     * Empty immutable.
+     */
+    public static <A, B> Tuple2List<A, B> tuple2List() {
+        return tuple2List(Cf.<Tuple2<A, B>>list());
+    }
+
+    public static <A, B> Tuple2List<A, B> arrayList() {
+        return tuple2List(Cf.<Tuple2<A, B>>arrayList());
+    }
+
+    public static <A, B> Tuple2List<A, B> tuple2List(Tuple2<A, B>... pairs) {
+        return tuple2List(Cf.list(pairs));
+    }
+
+    public static <A, B> Tuple2List<A, B> tuple2List(ListF<Tuple2<A, B>> pairs) {
+        return new Tuple2List<A, B>(pairs);
+    }
+
+} //~

src/main/java/ru/yandex/bolts/collection/Tuple2ListTest.java

+package ru.yandex.bolts.collection;
+
+import junit.framework.TestCase;
+
+import ru.yandex.bolts.function.Function1B;
+
+/**
+ * @author Stepan Koltsov
+ * @author Iliya Roubin
+ */
+public class Tuple2ListTest extends TestCase {
+
+    public void testFlatMapFromPairs() {
+        assertEquals(Tuple2List.tuple2List(), Tuple2List.fromPairs());
+
+        Tuple2List<String, Integer> fm = Tuple2List.fromPairs("a", 1, "b", 2);
+        assertEquals(2, fm.length());
+        assertEquals(Tuple2.tuple("a", 1), fm.get(0));
+        assertEquals(Tuple2.tuple("b", 2), fm.get(1));
+    }
+
+    public void testSortByKey() {
+        assertEquals(Tuple2List.fromPairs("a", 2, "a", 1, "b", 4), Tuple2List.fromPairs("b", 4, "a", 2, "a", 1).sortBy1());
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testPlus() {
+        Tuple2List<String, Integer> lm = Tuple2List.fromPairs("a", 1, "b", 2);
+        assertSame(lm, lm.plus(Tuple2List.<String, Integer>arrayList()));
+        assertSame(lm, Tuple2List.<String, Integer>arrayList().plus(lm));
+
+        assertEquals(Tuple2List.fromPairs("a", 1, "b", 2, "c", 3), Tuple2List.fromPairs("a", 1, "b", 2).plus(Tuple2List.fromPairs("c", 3)));
+        assertEquals(Tuple2List.<String, Integer>fromPairs("a", 1, "b", 2, "c", 3),
+                Tuple2List.<String, Integer>fromPairs("a", 1, "b", 2).plus(Tuple2.tuple("c", 3)));
+    }
+
+    public void testFilter() {
+        Tuple2List<String, Integer> lm = Tuple2List.fromPairs("a", 1, "b", 2);
+        Tuple2List<String, Integer> lmf = lm.filter(new Function1B<Tuple2<String, Integer>>() {
+            @Override
+            public boolean apply(Tuple2<String, Integer> t) {
+                return "a".equals(t.get1());
+            }
+        });
+        assertEquals(Tuple2List.<String, Integer>fromPairs("a", 1), lmf);
+    }
+
+    public void testPartitionLm() {
+        Tuple2List<String, Integer> lm = Tuple2List.fromPairs("a", 1, "b", 2);
+        Tuple2<Tuple2List<String, Integer>, Tuple2List<String, Integer>> t = lm.partitionT2l(new Function1B<Tuple2<String, Integer>>() {
+            @Override
+            public boolean apply(Tuple2<String, Integer> t) {
+                return "a".equals(t.get1());
+            }
+        });
+        assertEquals(Tuple2List.<String, Integer>fromPairs("a", 1), t.get1());
+        assertEquals(Tuple2List.<String, Integer>fromPairs("b", 2), t.get2());
+    }
+
+    public void testTakeDrop() {
+        Tuple2List<String, Integer> lm = Tuple2List.fromPairs("a", 1, "b", 2);
+        assertEquals(Tuple2List.<String, Integer>fromPairs("a", 1), lm.take(1));
+        assertEquals(Tuple2List.<String, Integer>fromPairs("b", 2), lm.drop(1));
+    }
+
+    public void testReverse() {
+        assertEquals(Tuple2List.fromPairs("a", 1, "b", 2),
+                Tuple2List.fromPairs("b", 2, "a", 1).reverse());
+    }
+
+    public void testMapPlusToArray() {
+        assertEquals(1, Tuple2List.fromPairs("a", 1).map(Tuple2.get2F()).plus(Cf.list(2)).toArray()[0]);
+        assertEquals(1, Tuple2List.tuple2List().map(Tuple2.get2F()).plus(Cf.list(1)).toArray()[0]);
+    }
+} //~

src/main/java/ru/yandex/bolts/collection/impl/AbstractListF.java

 import ru.yandex.bolts.collection.IteratorF;
 import ru.yandex.bolts.collection.ListF;
 import ru.yandex.bolts.collection.ListIteratorF;
-import ru.yandex.bolts.collection.ListMap;
 import ru.yandex.bolts.collection.Option;
 import ru.yandex.bolts.collection.Tuple2;
+import ru.yandex.bolts.collection.Tuple2List;
 import ru.yandex.bolts.function.Function;
 import ru.yandex.bolts.function.Function1B;
 
     }
 
     @Override
-    public ListMap<E, Integer> zipWithIndex() {
-        return ListMap.listMap(iterator().zipWithIndex().toList());
+    public Tuple2List<E, Integer> zipWithIndex() {
+        return Tuple2List.tuple2List(iterator().zipWithIndex().toList());
     }
 
     @SuppressWarnings({"unchecked"})
         };
     }
 
-    public <B> ListMap<E, B> zip(ListF<B> that) {
-        return ListMap.listMapFromKeysValues(this, that);
+    public <B> Tuple2List<E, B> zip(ListF<B> that) {
+        return Tuple2List.zip(this, that);
     }
 
     @Override
-    public <B> ListMap<E, B> zipWith(final Function<? super E, ? extends B> f) {
-        return ListMap.listMap(map(new Function<E, Tuple2<E, B>>() {
+    public <B> Tuple2List<E, B> zipWith(final Function<? super E, ? extends B> f) {
+        return Tuple2List.tuple2List(map(new Function<E, Tuple2<E, B>>() {
             public Tuple2<E, B> apply(E a) {
                 return Tuple2.<E, B>tuple(a, f.apply(a));
             }
     }
 
     @Override
-    public <B> ListMap<E, B> zipWithW(B f) {
+    public <B> Tuple2List<E, B> zipWithW(B f) {
         throw new RuntimeException("weaving must be enabled");
     }
 

src/main/java/ru/yandex/bolts/collection/impl/AbstractMapF.java

 import ru.yandex.bolts.collection.CollectionF;
 import ru.yandex.bolts.collection.CollectionsF;
 import ru.yandex.bolts.collection.ListF;
-import ru.yandex.bolts.collection.ListMap;
 import ru.yandex.bolts.collection.MapF;
 import ru.yandex.bolts.collection.Option;
 import ru.yandex.bolts.collection.SetF;
 import ru.yandex.bolts.collection.Tuple2;
+import ru.yandex.bolts.collection.Tuple2List;
 import ru.yandex.bolts.function.Function;
 import ru.yandex.bolts.function.Function0;
 import ru.yandex.bolts.function.Function1B;
 
     public abstract SetF<Entry<K, V>> entrySet();
 
-    public ListMap<K, V> entries() {
-        return ListMap.listMap(entrySet().map(AbstractMapF.<K, V>tupleM()));
+    public Tuple2List<K, V> entries() {
+        return Tuple2List.tuple2List(entrySet().map(AbstractMapF.<K, V>tupleM()));
     }
 
     protected boolean eq(Object a, Object b) {

src/main/java/ru/yandex/bolts/weaving/ClassTransformationResult.java

 package ru.yandex.bolts.weaving;
 
-import ru.yandex.bolts.collection.ListMap;
+import ru.yandex.bolts.collection.Tuple2List;
 
 /**
  * @author Stepan Koltsov
 public class ClassTransformationResult {
     private final byte[] transformedClass;
 
-    private final ListMap<String, byte[]> extraClasses;
+    private final Tuple2List<String, byte[]> extraClasses;
 
-    public ClassTransformationResult(byte[] transformedClass, ListMap<String, byte[]> extraClasses) {
+    public ClassTransformationResult(byte[] transformedClass, Tuple2List<String, byte[]> extraClasses) {
         this.transformedClass = transformedClass;
         this.extraClasses = extraClasses;
     }
         return transformedClass;
     }
 
-    public ListMap<String, byte[]> getExtraClasses() {
+    public Tuple2List<String, byte[]> getExtraClasses() {
         return extraClasses;
     }
 

src/main/java/ru/yandex/bolts/weaving/SecondPassVisitor.java

 import ru.yandex.bolts.collection.Cf;
 import ru.yandex.bolts.collection.IteratorF;
 import ru.yandex.bolts.collection.ListF;
-import ru.yandex.bolts.collection.ListMap;
 import ru.yandex.bolts.collection.Option;
+import ru.yandex.bolts.collection.Tuple2List;
 import ru.yandex.bolts.weaving.MethodInfo.LambdaInfo;
 
 public class SecondPassVisitor extends ClassAdapter {
 
     private int currentLambdaId;
 
-    ListMap<String, byte[]> extraClasses = ListMap.arrayList();
+    Tuple2List<String, byte[]> extraClasses = Tuple2List.arrayList();
 
     public SecondPassVisitor(ClassVisitor cv, FetchLambdaInfoVisitor fetchLambdaInfoVisitor, FunctionParameterCache functionParameterCache) {
         super(cv);