@Override default int length() { return size(); }
@SuppressWarnings("unchecked") static <K, V> boolean equals(Map<K, V> source, Object object) { if (source == object) { return true; } else if (source != null && object instanceof Map) { final Map<K, V> map = (Map<K, V>) object; if (source.size() != map.size()) { return false; } else { try { return source.forAll(map::contains); } catch (ClassCastException e) { return false; } } } else { return false; } }
static <K, V, M extends Map<K, V>> M takeWhile(M map, OfEntries<K, V, M> ofEntries, Predicate<? super Tuple2<K, V>> predicate) { Objects.requireNonNull(predicate, "predicate is null"); final M taken = ofEntries.apply(map.iterator().takeWhile(predicate)); return taken.size() == map.size() ? map : taken; }
static <K, V, M extends Map<K, V>> M dropRight(M map, OfEntries<K, V, M> ofEntries, Supplier<M> emptySupplier, int n) { if (n <= 0) { return map; } else if (n >= map.size()) { return emptySupplier.get(); } else { return ofEntries.apply(map.iterator().dropRight(n)); } }
static <K, V, M extends Map<K, V>> M drop(M map, OfEntries<K, V, M> ofEntries, Supplier<M> emptySupplier, int n) { if (n <= 0) { return map; } else if (n >= map.size()) { return emptySupplier.get(); } else { return ofEntries.apply(map.iterator().drop(n)); } }
static <K, V, M extends Map<K, V>> M take(M map, OfEntries<K, V, M> ofEntries, int n) { if (n >= map.size()) { return map; } else { return ofEntries.apply(map.iterator().take(n)); } }
static <K, V, M extends Map<K, V>> M takeRight(M map, OfEntries<K, V, M> ofEntries, int n) { if (n >= map.size()) { return map; } else { return ofEntries.apply(map.iterator().takeRight(n)); } }
@Override default int length() { return size(); }
@SuppressWarnings("unchecked") static <K, V> boolean equals(Map<K, V> source, Object object) { if (source == object) { return true; } else if (source != null && object instanceof Map) { final Map<K, V> map = (Map<K, V>) object; if (source.size() != map.size()) { return false; } else { try { return source.forAll(map::contains); } catch (ClassCastException e) { return false; } } } else { return false; } }
static <K, V, M extends Map<K, V>> M takeWhile(M map, OfEntries<K, V, M> ofEntries, Predicate<? super Tuple2<K, V>> predicate) { Objects.requireNonNull(predicate, "predicate is null"); final M taken = ofEntries.apply(map.iterator().takeWhile(predicate)); return taken.size() == map.size() ? map : taken; }
static <K, V, M extends Map<K, V>> M drop(M map, OfEntries<K, V, M> ofEntries, Supplier<M> emptySupplier, int n) { if (n <= 0) { return map; } else if (n >= map.size()) { return emptySupplier.get(); } else { return ofEntries.apply(map.iterator().drop(n)); } }
static <K, V, M extends Map<K, V>> M dropRight(M map, OfEntries<K, V, M> ofEntries, Supplier<M> emptySupplier, int n) { if (n <= 0) { return map; } else if (n >= map.size()) { return emptySupplier.get(); } else { return ofEntries.apply(map.iterator().dropRight(n)); } }
static <K, V, M extends Map<K, V>> M takeRight(M map, OfEntries<K, V, M> ofEntries, int n) { if (n >= map.size()) { return map; } else { return ofEntries.apply(map.iterator().takeRight(n)); } }
@Benchmark public int groupByJavaslangImmutable(Deck deck) { return deck.javaslangDeckOfCardsAsImmutableList.getCards().groupBy(Card::getSuit).size(); } }
@Benchmark public int groupByJavaslang(Deck deck) { return deck.javaslangDeckOfCards.getCards().groupBy(Card::getSuit).size(); }
static <K, V, M extends Map<K, V>> M take(M map, OfEntries<K, V, M> ofEntries, int n) { if (n >= map.size()) { return map; } else { return ofEntries.apply(map.iterator().take(n)); } }
private static void assertMetaDataParsedCorrectly(DataFrame df) { Map<String, String> dataFrameMetaData = df.getMetaData(); assertEquals(1, dataFrameMetaData.size()); assertEquals(Option.of("netzwerg"), dataFrameMetaData.get("author")); Map<String, String> columnMetaData = df.getColumn(df.getColumnId(2, ColumnType.DOUBLE)).getMetaData(); assertEquals(1, columnMetaData.size()); assertEquals(Option.of("m"), columnMetaData.get("unit")); }