SortedMap tailMap - 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 tailMap method.

This code example shows how to use the following methods:tailMap
        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() 
    { 
        this.delegate.clear();
    } 
 
    public V get(Object key) 
    { 
7
CodeRank
This code example shows how to use the following methods:tailMap
  public SortedMap<byte[], V> subMap(byte[] fromKey, byte[] toKey) {
    return this.instance.subMap(fromKey, toKey);
  } 
 
  public SortedMap<byte[], V> tailMap(byte[] fromKey) {
    return this.instance.tailMap(fromKey);
  } 
 
  // Writable 
 
  /** @return the Class class for the specified id */ 
  @SuppressWarnings("boxing") 
  protected Class<?> getClass(byte id) {
    return CODE_TO_CLASS.get(id);
  } 
 
  /** @return the id for the specified Class */ 
  @SuppressWarnings("boxing") 
  protected byte getId(Class<?> clazz) {
    Byte b = CLASS_TO_CODE.get(clazz);
7
CodeRank
This code example shows how to use the following methods:tailMap
        SortedMap<K, V> map = getSortedMap().headMap(toKey);
        return new LazySortedMap<K, V>(map, transformer);
    } 
 
    public SortedMap<K, V> tailMap(K fromKey) {
        SortedMap<K, V> map = getSortedMap().tailMap(fromKey);
        return new LazySortedMap<K, V>(map, transformer);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:containsKey, get, isEmpty, firstKey, tailMap
	public Set<String> getKeys(){
		return keyMap.keySet();
	} 
 
	public T get(String key) {
		if (circle.isEmpty()) {
			return null; 
		} 
		long hash = hashFunction.hashString(key).asLong();
		if (!circle.containsKey(hash)) {
			SortedMap<Long, T> tailMap = circle.tailMap(hash);
			hash = tailMap.isEmpty() ? circle.firstKey() : tailMap.firstKey();
		} 
		return circle.get(hash);
	} 
 
 
} 
6
CodeRank
This code example shows how to use the following methods:tailMap
     * 
     * @param  fromKey low endpoint (inclusive) of the sub list. 
     * @return A view of the specified final range of this list. 
     */ 
    public KeySortedList<K,V> tailList(final K fromKey) {
        return new KeySortedList<K,V>(map.tailMap(fromKey));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:get, isEmpty, firstKey, tailMap
   * This returns the closest bin for the object. If the object is the bin it 
   * should be an exact hit, but if it is a value traverse to find closest 
   * subsequent bin. 
   */ 
  public T getBinFor(Object key) { 
    if (circle.isEmpty()) {
      return null; 
    } 
    int hash = hashFunction.hash(key);
    T bin = circle.get(hash);
 
    if (bin == null) {
      // inexact match -- find the next value in the circle 
      SortedMap<Integer, T> tailMap = circle.tailMap(hash);
      hash = tailMap.isEmpty() ? circle.firstKey() : tailMap.firstKey();
      bin = circle.get(hash);
    } 
    return bin;
  } 
 
  /** 
7
CodeRank
This code example shows how to use the following methods:get, isEmpty, firstKey, tailMap
     *  such that translating it usually would make not to much sense 
     *  @return true, iff the given position has been cut away, false otherwise (i.e. false if it should be mappable) 
     *  TODO: current version ONLY WORKS SECURELY WHEN THERE IS ONLY ONE POSITION CHANGE RUN WITHOUT OVERLAPPING CHANGES! 
     *  as soon as there are more than one change runs, or changes that overlap, we would need to check all following changes instead of only the next one */ 
    public boolean hasBeenCutAway(Integer pos){
        SortedMap<Integer,Integer> tailMap=positionMap.tailMap(pos+1);
        if(tailMap.isEmpty())
          return false; 
        Integer key=tailMap.firstKey();
        Integer modifier=tailMap.get(key);
        if(modifier<0 && key+modifier<=pos )
          return true; 
        else  
          return false; 
        /* this does not work for the general case (had it the wrong way aroung), but can be used to implement it 
        Integer key=null; 
        Iterator<Integer> it=tailMap.keySet().iterator(); 
        while(it.hasNext()){ 
          key=it.next(); 
          Integer mod=tailMap.get(key); 
6
CodeRank
This code example shows how to use the following methods:tailMap
        return UnmodifiableTreeMap.of(this.getSortedMap().headMap(toKey));
    } 
 
    public SortedMap<K, V> tailMap(K fromKey)
    { 
        return UnmodifiableTreeMap.of(this.getSortedMap().tailMap(fromKey));
    } 
 
    public K firstKey() 
    { 
        return this.getSortedMap().firstKey();
    } 
 
    public K lastKey() 
    { 
        return this.getSortedMap().lastKey();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:size, entrySet, tailMap
      public SocketAddress getServer(byte[] key) {
         int keyHashCode = getNormalizedHash(key);
         if (keyHashCode == Integer.MIN_VALUE) keyHashCode += 1;
         int hash = Math.abs(keyHashCode);
 
         SortedMap<Integer, SocketAddress> candidates = positions.tailMap(hash % hashSpace);
         if (log.isTraceEnabled()) {
            log.tracef("Found possible candidates: %s", candidates);
         } 
         return (candidates.size() > 0 ? candidates : positions).entrySet().iterator().next().getValue();
      } 
 
      private SocketAddress getItemAtPosition(int position, SortedMap<Integer, SocketAddress> map) {
         Iterator<Map.Entry<Integer,SocketAddress>> iterator = map.entrySet().iterator();
         for (int i = 0; i < position; i++) {
            iterator.next();
         } 
         return iterator.next().getValue();
      } 
 
7
CodeRank
This code example shows how to use the following methods:size, headMap, subMap, tailMap
		sortedMap.put("5", "five");
		sortedMap.put("4", "four");
    } 
	 
	public void testHeadMapTailMapSubMap() {	 
		Map<String, String> map = sortedMap.headMap("3");
		assertEquals(2, map.size());
		 
		map = sortedMap.tailMap("4");
		assertEquals(2, map.size());
		 
		map = sortedMap.subMap("2", "4");
		assertEquals(2, map.size());
		 
		assertEquals(5, sortedMap.size());
	} 
	 
	public void testFirstKeyLastKey() { 
		assertEquals("1", sortedMap.firstKey());
		assertEquals("5", sortedMap.lastKey());
6
CodeRank
tailMap Method Overview
Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
See Code Examples for other Java 8 SortedMap Methods: