@Test public void iterationIsInOrder() { for (Map<Integer, Integer> any : someMaps(integers(), integers())) { List<Integer> expectedKeys = new ArrayList<>(any.keySet()); Collections.sort(expectedKeys); ImmutableSortedMap<Integer, Integer> map = ArraySortedMap.fromMap(any, IntComparator); List<Integer> actualKeys = new ArrayList<>(); for (Map.Entry<Integer, Integer> entry : map) { actualKeys.add(entry.getKey()); } Assert.assertEquals(expectedKeys, actualKeys); } }
public static <K, V> ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator) { return buildFrom( new ArrayList<K>(map.keySet()), map, Builder.<K>identityTranslator(), comparator); }
ArraySortedMap extends ImmutableSortedMap<K, V> { public static <K, V> ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator) { return buildFrom( new ArrayList<K>(map.keySet()), map, Builder.<K>identityTranslator(), comparator); } }
ArraySortedMap extends ImmutableSortedMap<K, V> { public static <K, V> ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator) { return buildFrom( new ArrayList<K>(map.keySet()), map, Builder.<K>identityTranslator(), comparator); } @SuppressWarnings("unchecked")  ArraySortedMap(Comparator<K> comparator); @SuppressWarnings("unchecked") private  ArraySortedMap(Comparator<K> comparator, K[] keys, V[] values); }
ArraySortedMap extends ImmutableSortedMap<K, V> { public static <K, V> ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator) { return buildFrom( new ArrayList<K>(map.keySet()), map, Builder.<K>identityTranslator(), comparator); } @SuppressWarnings("unchecked")  ArraySortedMap(Comparator<K> comparator); @SuppressWarnings("unchecked") private  ArraySortedMap(Comparator<K> comparator, K[] keys, V[] values); @SuppressWarnings("unchecked") static ArraySortedMap<A, C> buildFrom(
      List<A> keys,
      Map<B, C> values,
      Builder.KeyTranslator<A, B> translator,
      Comparator<A> comparator); static ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator); @Override boolean containsKey(K key); @Override V get(K key); @Override ImmutableSortedMap<K, V> remove(K key); @Override ImmutableSortedMap<K, V> insert(K key, V value); @Override K getMinKey(); @Override K getMaxKey(); @Override int size(); @Override boolean isEmpty(); @Override void inOrderTraversal(LLRBNode.NodeVisitor<K, V> visitor); @Override Iterator<Map.Entry<K, V>> iterator(); @Override Iterator<Map.Entry<K, V>> iteratorFrom(K key); @Override Iterator<Map.Entry<K, V>> reverseIteratorFrom(K key); @Override Iterator<Map.Entry<K, V>> reverseIterator(); @Override K getPredecessorKey(K key); @Override K getSuccessorKey(K key); @Override int indexOf(K key); @Override Comparator<K> getComparator(); }
ArraySortedMap extends ImmutableSortedMap<K, V> { public static <K, V> ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator) { return buildFrom( new ArrayList<K>(map.keySet()), map, Builder.<K>identityTranslator(), comparator); } @SuppressWarnings("unchecked")  ArraySortedMap(Comparator<K> comparator); @SuppressWarnings("unchecked") private  ArraySortedMap(Comparator<K> comparator, K[] keys, V[] values); @SuppressWarnings("unchecked") static ArraySortedMap<A, C> buildFrom(
      List<A> keys,
      Map<B, C> values,
      Builder.KeyTranslator<A, B> translator,
      Comparator<A> comparator); static ArraySortedMap<K, V> fromMap(Map<K, V> map, Comparator<K> comparator); @Override boolean containsKey(K key); @Override V get(K key); @Override ImmutableSortedMap<K, V> remove(K key); @Override ImmutableSortedMap<K, V> insert(K key, V value); @Override K getMinKey(); @Override K getMaxKey(); @Override int size(); @Override boolean isEmpty(); @Override void inOrderTraversal(LLRBNode.NodeVisitor<K, V> visitor); @Override Iterator<Map.Entry<K, V>> iterator(); @Override Iterator<Map.Entry<K, V>> iteratorFrom(K key); @Override Iterator<Map.Entry<K, V>> reverseIteratorFrom(K key); @Override Iterator<Map.Entry<K, V>> reverseIterator(); @Override K getPredecessorKey(K key); @Override K getSuccessorKey(K key); @Override int indexOf(K key); @Override Comparator<K> getComparator();  }