SortedMap comparator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SortedMap comparator method.

This code example shows how to use the following methods:comparator
	 * @see java.util.LinkedHashMap 
	 */ 
	@SuppressWarnings("unchecked") 
	public static <K, V> Map<K, V> createApproximateMap(Object map, int initialCapacity) {
		if (map instanceof SortedMap) {
			return new TreeMap<K, V>(((SortedMap<K, V>) map).comparator());
		} 
		else { 
			return new LinkedHashMap<K, V>(initialCapacity);
		} 
	} 
 
	/** 
	 * Create the most approximate map for the given map. 
	 * <p>Creates a TreeMap or linked Map for a SortedMap or Map, respectively. 
	 * @param mapType the desired type of the target Map 
	 * @param initialCapacity the initial capacity 
	 * @return the new Map instance 
	 * @see java.util.TreeMap 
	 * @see java.util.LinkedHashMap 
8
CodeRank
This code example shows how to use the following methods:comparator
        return (SortedMap<K, V>) this.delegate;
    } 
 
    public Comparator<? super K> comparator()
    { 
        return this.getSortedMap().comparator();
    } 
 
    public SortedMap<K, V> subMap(K fromKey, K toKey)
    { 
        return UnmodifiableTreeMap.of(this.getSortedMap().subMap(fromKey, toKey));
    } 
 
    public SortedMap<K, V> headMap(K toKey)
    { 
        return UnmodifiableTreeMap.of(this.getSortedMap().headMap(toKey));
    } 
 
    public SortedMap<K, V> tailMap(K fromKey)
    { 
7
CodeRank
This code example shows how to use the following methods:comparator
     * @deprecated use {@link TreeSortedMap#newEmpty()} instead (inlineable) 
     */ 
    @Deprecated 
    public MutableSortedMap<K, V> newEmpty() 
    { 
        return TreeSortedMap.newMap(this.delegate.comparator());
    } 
 
    public boolean containsKey(Object key) 
    { 
        return this.delegate.containsKey(key);
    } 
 
    public boolean containsValue(Object value) 
    { 
        return this.delegate.containsValue(value);
    } 
 
    public Comparator<? super K> comparator()
    { 
7
CodeRank
This code example shows how to use the following methods:comparator
  public V put(byte [] key, V value) {
    return this.instance.put(key, value);
  } 
 
  public Comparator<? super byte[]> comparator() {
    return this.instance.comparator();
  } 
 
  public byte[] firstKey() { 
    return this.instance.firstKey();
  } 
 
  public SortedMap<byte[], V> headMap(byte[] toKey) {
    return this.instance.headMap(toKey);
  } 
 
  public byte[] lastKey() { 
    return this.instance.lastKey();
  } 
 
7
CodeRank
This code example shows how to use the following methods:comparator
      return new Maps.SortedKeySet<R, Map<C, V>>(this);
    } 
 
    @Override 
    public Comparator<? super R> comparator() {
      return sortedBackingMap().comparator();
    } 
 
    @Override 
    public R firstKey() { 
      return sortedBackingMap().firstKey();
    } 
 
    @Override 
    public R lastKey() { 
      return sortedBackingMap().lastKey();
    } 
 
    @Override 
    public SortedMap<R, Map<C, V>> headMap(R toKey) {
7
CodeRank
This code example shows how to use the following methods:comparator
      return Collections.unmodifiableSet(this.internalMap.keySet());
    } 
  } 
 
  public Comparator<? super K> comparator() {
    return this.internalMap.comparator();
  } 
 
  public Set<Map.Entry<K,V>> entrySet() {
    synchronized(sync) { 
      checkReferences(); 
      // this is not correct as per SortedMap contract (entrySet should be 
      // backed by map) 
      Set<Map.Entry<K, V>> realEntries = new LinkedHashSet<Map.Entry<K, V>>(); 
      for (Map.Entry<K, SoftValue<K, V>> entry : this.internalMap.entrySet()) {
        realEntries.add(entry.getValue()); 
      } 
      return realEntries; 
    } 
  } 
7
CodeRank
This code example shows how to use the following methods:comparator
			init(clone ? new TreeMap<K, V>(collection) : collection, null, false);
	} 
	 
	@Override 
	public void doInitialize(SortedMap<K, V> sortedMap, boolean empty) {
		init(empty ? new TreeMap<K, V>(sortedMap.comparator()) : sortedMap, null, false);
	} 
	 
	public Comparator<? super K> comparator() {
		return getCollection().comparator(); 
	} 
 
	public SortedMap<K, V> subMap(K fromKey, K toKey) {
		if (!checkInitializedRead()) 
			return null; 
		return new SortedMapProxy<K, V>(getCollection().subMap(fromKey, toKey));
	} 
 
	public SortedMap<K, V> headMap(K toKey) {
		if (!checkInitializedRead()) 
6
CodeRank
This code example shows how to use the following methods:comparator
        return (SortedMap<K, V>) map;
    } 
 
    //----------------------------------------------------------------------- 
    public Comparator<? super K> comparator() {
        return getSortedMap().comparator();
    } 
 
    public K firstKey() { 
        return getSortedMap().firstKey();
    } 
 
    public SortedMap<K, V> headMap(K toKey) {
        return getSortedMap().headMap(toKey);
    } 
 
    public K lastKey() { 
        return getSortedMap().lastKey();
    } 
 
5
CodeRank
This code example shows how to use the following methods:comparator
            sortedDelegate = wrapped;
        } 
 
        @Override 
        public Comparator<? super K> comparator() {
            return sortedDelegate.comparator();
        } 
 
        @Override 
        public SortedSet<K> subSet( K fromElement,
                                    K toElement ) {
            return new WrappedSortedKeySet(sortedDelegate.subMap(fromElement, toElement));
        } 
 
        @Override 
        public SortedSet<K> headSet( K toElement ) {
            return new WrappedSortedKeySet(sortedDelegate.headMap(toElement));
        } 
 
        @Override 
6
CodeRank
This code example shows how to use the following methods:comparator
        return delegate.entrySet();
    } 
 
    public Comparator<? super K> comparator() {
        checkInit(); 
        return delegate.comparator();
    } 
 
    public SortedMap<K, V> subMap(K k, K k1) {
        checkInit(); 
        return delegate.subMap(k, k1);
    } 
 
    public SortedMap<K, V> headMap(K k) {
        checkInit(); 
        return delegate.headMap(k);
    } 
 
    public SortedMap<K, V> tailMap(K k) {
        checkInit(); 
6
CodeRank
comparator Method Overview
Returns the comparator used to order the keys in this map, or null if this map uses the Comparable natural ordering of its keys.
See Code Examples for other Java 8 SortedMap Methods: