/** * @param <V> * @param key * @param value * @return empty().plus(key, value) */ public static <V> IntTreePMap<V> singleton(final Integer key, final V value) { return IntTreePMap.<V>empty().plus(key, value); }
/** * @param <V> * @param map * @return empty().plusAll(map) */ @SuppressWarnings("unchecked") public static <V> IntTreePMap<V> from(final Map<? extends Integer, ? extends V> map) { if(map instanceof IntTreePMap) return (IntTreePMap<V>)map; //(actually we only know it's IntTreePMap<? extends V>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return IntTreePMap.<V>empty().plusAll(map); }
/** * @param <V> * @param map * @return empty().plusAll(map) */ @SuppressWarnings("unchecked") public static <V> IntTreePMap<V> from(final Map<? extends Integer, ? extends V> map) { if(map instanceof IntTreePMap) return (IntTreePMap<V>)map; //(actually we only know it's IntTreePMap<? extends V>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return IntTreePMap.<V>empty().plusAll(map); }
/** * @param <V> * @param key * @param value * @return empty().plus(key, value) */ public static <V> IntTreePMap<V> singleton(final Integer key, final V value) { return IntTreePMap.<V>empty().plus(key, value); }
public void testSingleton() { UtilityTest.assertEqualsAndHash(IntTreePMap.empty().plus(10, "test"), IntTreePMap.singleton(10, "test")); }
public void testEmpty() { PMap<?,?> empty = IntTreePMap.empty(); UtilityTest.assertEqualsAndHash(new HashMap<Object,Object>(), empty); assertEquals(0, empty.size()); assertTrue(empty.isEmpty()); for(@SuppressWarnings("unused") Object e : empty.entrySet()) fail(); }
/** * @param <V> * @param key * @param value * @return empty().plus(key, value) */ public static <V> IntTreePMap<V> singleton(final Integer key, final V value) { return IntTreePMap.<V>empty().plus(key, value); }
/** * @param <V> * @param key * @param value * @return empty().plus(key, value) */ public static <V> IntTreePMap<V> singleton(final Integer key, final V value) { return IntTreePMap.<V>empty().plus(key, value); }
/** * @param <V> * @param map * @return empty().plusAll(map) */ @SuppressWarnings("unchecked") public static <V> IntTreePMap<V> from(final Map<? extends Integer, ? extends V> map) { if(map instanceof IntTreePMap) return (IntTreePMap<V>)map; //(actually we only know it's IntTreePMap<? extends V>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return IntTreePMap.<V>empty().plusAll(map); }
/** * @param <V> * @param map * @return empty().plusAll(map) */ @SuppressWarnings("unchecked") public static <V> IntTreePMap<V> from(final Map<? extends Integer, ? extends V> map) { if (map instanceof IntTreePMap) return (IntTreePMap<V>) map; //(actually we only know it's IntTreePMap<? extends V>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return IntTreePMap.<V>empty().plusAll(map); }