Skip to content

Commit 2abd6bb

Browse files
committed
Issue #4: Renamed static constructor TreeMap.map to treeMap
1 parent 0645ad9 commit 2abd6bb

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

core/src/main/java/fj/data/TreeMap.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public static <K, V> TreeMap<K, V> empty(final Ord<K> keyOrd) {
4747
* @param p2s The elements to construct the tree map with.
4848
* @return a TreeMap with the given elements.
4949
*/
50-
public static <K, V> TreeMap<K, V> map(final Ord<K> keyOrd, final P2<K, V> ... p2s) {
51-
return map(keyOrd, List.list(p2s));
50+
public static <K, V> TreeMap<K, V> treeMap(final Ord<K> keyOrd, final P2<K, V>... p2s) {
51+
return treeMap(keyOrd, List.list(p2s));
5252
}
5353

5454
/**
@@ -58,7 +58,7 @@ public static <K, V> TreeMap<K, V> map(final Ord<K> keyOrd, final P2<K, V> ... p
5858
* @param list The elements to construct the tree map with.
5959
* @return a TreeMap with the given elements.
6060
*/
61-
public static <K, V> TreeMap<K, V> map(final Ord<K> keyOrd, final List<P2<K, V>> list) {
61+
public static <K, V> TreeMap<K, V> treeMap(final Ord<K> keyOrd, final List<P2<K, V>> list) {
6262
TreeMap<K, V> tm = empty(keyOrd);
6363
for (final P2<K, V> p2 : list) {
6464
tm = tm.set(p2._1(), p2._2());
@@ -249,7 +249,7 @@ public P3<Set<V>, Option<V>, Set<V>> split(Ord<V> ord, final K k) {
249249
* @param s The elements to construct the tree map with.
250250
* @return a TreeMap with the given elements.
251251
*/
252-
private static <K, V> TreeMap<K, V> map(Ord<K> ord, Set<P2<K, Option<V>>> s) {
252+
private static <K, V> TreeMap<K, V> treeMap(Ord<K> ord, Set<P2<K, Option<V>>> s) {
253253
TreeMap<K, V> empty = TreeMap.<K, V>empty(ord);
254254
TreeMap<K, V> tree = s.toList().foldLeft((tm, p2) -> {
255255
Option<V> opt = p2._2();
@@ -278,7 +278,7 @@ private static <K, V> TreeMap<K, V> map(Ord<K> ord, Set<P2<K, Option<V>>> s) {
278278
public P3<TreeMap<K, V>, Option<V>, TreeMap<K, V>> splitLookup(final K k) {
279279
P3<Set<P2<K, Option<V>>>, Option<P2<K, Option<V>>>, Set<P2<K, Option<V>>>> p3 = tree.split(P.p(k, get(k)));
280280
Ord<K> o = tree.ord().<K>comap(k2 -> P.p(k2, Option.<V>none()));
281-
return P.p(map(o, p3._1()), get(k), map(o, p3._3()));
281+
return P.p(treeMap(o, p3._1()), get(k), treeMap(o, p3._3()));
282282
}
283283

284284
/**

core/src/test/java/fj/data/TreeMapTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import fj.P3;
66
import fj.Show;
77
import fj.P;
8-
import org.junit.Assert;
98
import org.junit.Test;
109

1110
import static fj.data.Option.some;
@@ -22,7 +21,7 @@ public void split() {
2221
int pivot = 4;
2322
int max = 5;
2423
List<Integer> l = List.range(1, max + 1);
25-
TreeMap<Integer, String> m2 = TreeMap.map(Ord.intOrd, l.zip(l.map(i -> i.toString())));
24+
TreeMap<Integer, String> m2 = TreeMap.treeMap(Ord.intOrd, l.zip(l.map(i -> i.toString())));
2625
P3<Set<String>, Option<String>, Set<String>> p = m2.split(Ord.stringOrd, pivot);
2726

2827
// print debug info
@@ -53,14 +52,14 @@ public void splitLookup() {
5352
int pivot = 4;
5453
int max = 5;
5554
List<Integer> l = List.range(1, max + 1);
56-
TreeMap<Integer, String> m2 = TreeMap.map(Ord.intOrd, l.zip(l.map(i -> i.toString())));
55+
TreeMap<Integer, String> m2 = TreeMap.treeMap(Ord.intOrd, l.zip(l.map(i -> i.toString())));
5756
P3<TreeMap<Integer, String>, Option<String>, TreeMap<Integer, String>> p3 = m2.splitLookup(pivot);
5857

5958
// create expected output
6059
List<Integer> leftList = List.range(1, pivot);
61-
TreeMap<Integer, String> leftMap = TreeMap.map(Ord.intOrd, leftList.zip(leftList.map(i -> i.toString())));
60+
TreeMap<Integer, String> leftMap = TreeMap.treeMap(Ord.intOrd, leftList.zip(leftList.map(i -> i.toString())));
6261
List<Integer> rightList = List.range(pivot + 1, max + 1);
63-
TreeMap<Integer, String> rightMap = TreeMap.map(Ord.intOrd, rightList.zip(rightList.map(i -> i.toString())));
62+
TreeMap<Integer, String> rightMap = TreeMap.treeMap(Ord.intOrd, rightList.zip(rightList.map(i -> i.toString())));
6463

6564
// debug info
6665
if (true) {

0 commit comments

Comments
 (0)