@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 = RBTreeSortedMap.fromMap(any, IntComparator); List<Integer> actualKeys = new ArrayList<>(); for (Map.Entry<Integer, Integer> entry : map) { actualKeys.add(entry.getKey()); } assertEquals(expectedKeys, actualKeys); } }
public static <A, B> RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator) { return Builder.buildFrom( new ArrayList<>(values.keySet()), values, ImmutableSortedMap.Builder.identityTranslator(), comparator); }
RBTreeSortedMap extends ImmutableSortedMap<K, V> { public static <A, B> RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator) { return Builder.buildFrom( new ArrayList<>(values.keySet()), values, ImmutableSortedMap.Builder.identityTranslator(), comparator); } }
RBTreeSortedMap extends ImmutableSortedMap<K, V> { public static <A, B> RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator) { return Builder.buildFrom( new ArrayList<>(values.keySet()), values, ImmutableSortedMap.Builder.identityTranslator(), comparator); } RBTreeSortedMap(Comparator<K> comparator); private  RBTreeSortedMap(LLRBNode<K, V> root, Comparator<K> comparator); }
RBTreeSortedMap extends ImmutableSortedMap<K, V> { public static <A, B> RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator) { return Builder.buildFrom( new ArrayList<>(values.keySet()), values, ImmutableSortedMap.Builder.identityTranslator(), comparator); } RBTreeSortedMap(Comparator<K> comparator); private  RBTreeSortedMap(LLRBNode<K, V> root, 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(); static RBTreeSortedMap<A, C> buildFrom(
      List<A> keys,
      Map<B, C> values,
      ImmutableSortedMap.Builder.KeyTranslator<A, B> translator,
      Comparator<A> comparator); static RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator); }
RBTreeSortedMap extends ImmutableSortedMap<K, V> { public static <A, B> RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator) { return Builder.buildFrom( new ArrayList<>(values.keySet()), values, ImmutableSortedMap.Builder.identityTranslator(), comparator); } RBTreeSortedMap(Comparator<K> comparator); private  RBTreeSortedMap(LLRBNode<K, V> root, 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(); static RBTreeSortedMap<A, C> buildFrom(
      List<A> keys,
      Map<B, C> values,
      ImmutableSortedMap.Builder.KeyTranslator<A, B> translator,
      Comparator<A> comparator); static RBTreeSortedMap<A, B> fromMap(Map<A, B> values, Comparator<A> comparator);  }