Java 8 SortedMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SortedMap class.

This code example shows how to use the following methods:get, isEmpty, firstKey
        return resources.get(getShardInfo(key));
    } 
 
    public S getShardInfo(byte[] key) {
        SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
        if (tail.isEmpty()) {
            return nodes.get(nodes.firstKey());
        } 
        return tail.get(tail.firstKey());
    } 
 
    public S getShardInfo(String key) {
        return getShardInfo(SafeEncoder.encode(getKeyTag(key)));
    } 
 
    /** 
     * A key tag is a special pattern inside a key that, if preset, is the only 
     * part of the key hashed in order to select the server for this key. 
     * 
     * @see http://code.google.com/p/redis/wiki/FAQ#I 
8
CodeRank
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:values
        items.put(priority, item);
    } 
 
    public List<T> getSortedItems() {
        if(sortedItems == null) {
            final SortedMap<Integer, T> sortedMap = new TreeMap<Integer, T>(items);
            sortedItems = new ArrayList<T>(sortedMap.values());
        } 
        return sortedItems;
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:lastKey
        return this.getSortedMap().firstKey();
    } 
 
    public K lastKey() 
    { 
        return this.getSortedMap().lastKey();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:headMap
        return this.delegate.lastKey();
    } 
 
    public MutableSortedMap<K, V> headMap(K toKey)
    { 
        return SortedMapAdapter.adapt(this.delegate.headMap(toKey));
    } 
 
    public MutableSortedMap<K, V> tailMap(K fromKey)
    { 
        return SortedMapAdapter.adapt(this.delegate.tailMap(fromKey));
    } 
 
    public MutableSortedMap<K, V> subMap(K fromKey, K toKey)
    { 
        return SortedMapAdapter.adapt(this.delegate.subMap(fromKey, toKey));
    } 
 
    public void clear() 
    { 
7
CodeRank
This code example shows how to use the following methods:containsKey, keySet, firstKey, lastKey
 
        series = new TimeSeries(prices);
 
        SortedMap<DateTime, BigDecimal> slice = series.dateSlice(today.plusDays(1), today.plusDays(7));
 
        assertEquals(today.plusDays(1), slice.firstKey());
        assertTrue(slice.containsKey(today.plusDays(2)));
        assertEquals(today.plusDays(7), slice.lastKey());
        assertEquals(3, slice.keySet().size());
    } 
} 
9
CodeRank
This code example shows how to use the following methods:keySet
  public boolean has(String name) {
    return children != null && children.containsKey(name);
  } 
 
  public Set<String> keySet() {
    return children == null ? Collections.<String>emptySet() : children.keySet();
  } 
 
  public String toString() {
    return toString("WikiPageProperty root", 0); 
  } 
 
  protected String toString(String key, int depth) {
    StringBuffer buffer = new StringBuffer();
 
    for (int i = 0; i < depth; i++)
      buffer.append("\t");
    buffer.append(key);
    if (getValue() != null) 
      buffer.append(" = ").append(getValue());
7
CodeRank
This code example shows how to use the following methods:clear
 
		return false; 
	} 
 
	public static void clearAll() { 
		_tokens.clear();
	} 
 
	public static String createToken(long timeTolive) {
		long currentTime = System.currentTimeMillis();
 
		long expireTime = currentTime + timeTolive;
 
		_expungeExpiredToken(currentTime);
 
		String token = PortalUUIDUtil.generate();
 
		_tokens.put(expireTime, token);
 
		return token;
7
CodeRank
This code example shows how to use the following methods:get
 
    @Test 
    public void testParameterOptions() throws Exception { 
        CommandLineArgs lineArgs = parseArgs("Reproject", "-PpixelSizeX=0.02", "-PpixelSizeY=0.03", "-PpixelOffsetX=0.5", "-PpixelOffsetY=1.0", "source.dim");
        SortedMap<String, String> parameterMap = lineArgs.getParameterMap();
        assertEquals("0.02", parameterMap.get("pixelSizeX"));
        assertEquals("0.03", parameterMap.get("pixelSizeY"));
        assertEquals("0.5", parameterMap.get("pixelOffsetX"));
        assertEquals("1.0", parameterMap.get("pixelOffsetY"));
    } 
 
 
    @Test 
    public void testParametersFileOption() throws Exception { 
        CommandLineArgs lineArgs = parseArgs("Reproject", "source.dim", "-p", "param.properties");
        assertEquals("param.properties", lineArgs.getParameterFilePath());
    } 
 
    @Test 
    public void testMetadataFileOption() throws Exception { 
7
CodeRank
This code example shows how to use the following methods:get, put
   * @param inc 
   *          the incremental value 
   * @return the updated value. 
   */ 
  protected Long addLongValue(Object name, long inc) {
    Long val = this.longCounters.get(name);
    Long retv = null;
    if (val == null) {
      retv = Long.valueOf(inc);
    } else { 
      retv = Long.valueOf(val.longValue() + inc);
    } 
    this.longCounters.put(name, retv);
    return retv;
  } 
 
  /** 
   * Increment the given counter by the given incremental value If the counter 
   * does not exist, one is created with value 0. 
   *  
7
CodeRank

Related Java 8 SortedMap Questions & Answers:

See Code Examples for Java 8 SortedMap Methods: