Tabnine Logo
SortedMap
Code IndexAdd Tabnine to your IDE (free)

How to use
SortedMap
in
java.util

Best Java code snippets using java.util.SortedMap (Showing top 20 results out of 21,708)

origin: google/guava

public void testTailMapWriteThrough() {
 final SortedMap<K, V> map;
 try {
  map = makePopulatedMap();
 } catch (UnsupportedOperationException e) {
  return;
 }
 if (map.size() < 2 || !supportsPut) {
  return;
 }
 Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
 Entry<K, V> firstEntry = iterator.next();
 Entry<K, V> secondEntry = iterator.next();
 K key = secondEntry.getKey();
 SortedMap<K, V> subMap = map.tailMap(key);
 V value = getValueNotInPopulatedMap();
 subMap.put(key, value);
 assertEquals(secondEntry.getValue(), value);
 assertEquals(map.get(key), value);
 try {
  subMap.put(firstEntry.getKey(), value);
  fail("Expected IllegalArgumentException");
 } catch (IllegalArgumentException expected) {
 }
}
origin: neo4j/neo4j

@Override
public Iterable<Relationship> getRelationships()
{
  return relationships.values();
}
origin: jenkinsci/jenkins

public Set<Integer> keySet() {
  return core.keySet();
}
origin: prestodb/presto

/**
 * Answer the starting address of observed memory chunk
 *
 * @return starting address
 */
public long startAddress() {
  if (!addresses.isEmpty()) {
    return addresses.firstKey();
  } else {
    return 0;
  }
}
origin: prestodb/presto

/**
 * Answer the ending address of observed memory chunk
 *
 * @return ending address
 */
public long endAddress() {
  if (!addresses.isEmpty()) {
    return addresses.lastKey();
  } else {
    return 0;
  }
}
origin: jenkinsci/jenkins

/**
 * Gets the latest build #m that satisfies {@code m&lt;=n}.
 * 
 * This is useful when you'd like to fetch a build but the exact build might
 * be already gone (deleted, rotated, etc.)
 * @see LazyBuildMixIn#getNearestOldBuild
 */
public RunT getNearestOldBuild(int n) {
  SortedMap<Integer, ? extends RunT> m = _getRuns().tailMap(n);
  if (m.isEmpty())
    return null;
  return m.get(m.firstKey());
}
origin: redisson/redisson

@Override
protected Map<Integer, TypeDefinition> resolveInitializationTypes(ArgumentHandler argumentHandler) {
  SortedMap<Integer, TypeDefinition> namedTypes = new TreeMap<Integer, TypeDefinition>();
  for (Map.Entry<String, TypeDefinition> entry : this.namedTypes.entrySet()) {
    namedTypes.put(argumentHandler.named(entry.getKey()), entry.getValue());
  }
  return namedTypes;
}
origin: commons-collections/commons-collections

public void testFactory_Decorate() {
  SortedMap base = new TreeMap();
  base.put("A", "1");
  base.put("B", "2");
  base.put("C", "3");
  
  SortedMap trans = TransformedSortedMap.decorate(base, null, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
  assertEquals(3, trans.size());
  assertEquals("1", trans.get("A"));
  assertEquals("2", trans.get("B"));
  assertEquals("3", trans.get("C"));
  trans.put("D", "4");
  assertEquals(new Integer(4), trans.get("D"));
}
origin: apache/hbase

private void addRegion(SortedMap<Long, Collection<HRegion>> sortedRegions, HRegion region,
  long size) {
 if (!sortedRegions.containsKey(size)) {
  sortedRegions.put(size, new ArrayList<>());
 }
 sortedRegions.get(size).add(region);
}
/**
origin: google/guava

public void testTailMapRemoveThrough() {
 final SortedMap<K, V> map;
 try {
  map = makePopulatedMap();
 } catch (UnsupportedOperationException e) {
  return;
 }
 int oldSize = map.size();
 if (map.size() < 2 || !supportsRemove) {
  return;
 }
 Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
 Entry<K, V> firstEntry = iterator.next();
 Entry<K, V> secondEntry = iterator.next();
 K key = secondEntry.getKey();
 SortedMap<K, V> subMap = map.tailMap(key);
 subMap.remove(key);
 assertNull(subMap.remove(firstEntry.getKey()));
 assertEquals(map.size(), oldSize - 1);
 assertFalse(map.containsKey(key));
 assertEquals(subMap.size(), oldSize - 2);
}
origin: google/guava

 public void testTailMapClearThrough() {
  final SortedMap<K, V> map;
  try {
   map = makePopulatedMap();
  } catch (UnsupportedOperationException e) {
   return;
  }
  int oldSize = map.size();
  if (map.size() < 2 || !supportsClear) {
   return;
  }
  Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
  iterator.next(); // advance
  Entry<K, V> secondEntry = iterator.next();
  K key = secondEntry.getKey();
  SortedMap<K, V> subMap = map.tailMap(key);
  int subMapSize = subMap.size();
  subMap.clear();
  assertEquals(map.size(), oldSize - subMapSize);
  assertTrue(subMap.isEmpty());
 }
}
origin: google/guava

public void testAsMapSortedEmpty() {
 SortedSet<String> strings = new NonNavigableSortedSet();
 SortedMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertThat(map.entrySet()).isEmpty();
 assertTrue(map.isEmpty());
 assertNull(map.get("five"));
}
origin: jenkinsci/jenkins

/**
 * Gets the youngest build #m that satisfies {@code n&lt;=m}.
 * 
 * This is useful when you'd like to fetch a build but the exact build might
 * be already gone (deleted, rotated, etc.)
 * @see LazyBuildMixIn#getNearestBuild
 */
public RunT getNearestBuild(int n) {
  SortedMap<Integer, ? extends RunT> m = _getRuns().headMap(n - 1); // the map should
                                   // include n, so n-1
  if (m.isEmpty())
    return null;
  return m.get(m.lastKey());
}
origin: google/guava

public void testAsMapSorted() {
 SortedSet<String> strings = new NonNavigableSortedSet();
 Collections.addAll(strings, "one", "two", "three");
 SortedMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertEquals(ImmutableMap.of("one", 3, "two", 3, "three", 5), map);
 assertEquals(Integer.valueOf(5), map.get("three"));
 assertNull(map.get("five"));
 assertThat(map.entrySet())
   .containsExactly(mapEntry("one", 3), mapEntry("three", 5), mapEntry("two", 3))
   .inOrder();
 assertThat(map.tailMap("onea").entrySet())
   .containsExactly(mapEntry("three", 5), mapEntry("two", 3))
   .inOrder();
 assertThat(map.subMap("one", "two").entrySet())
   .containsExactly(mapEntry("one", 3), mapEntry("three", 5))
   .inOrder();
}
origin: apache/storm

public Object getPreviousState(long txid) {
  final SortedMap<Long, Object> prevMap = _curr.headMap(txid);
  Object state;
  if (prevMap.isEmpty()) {
    state = null;
  } else {
    state = prevMap.get(prevMap.lastKey());
  }
  LOG.debug("Getting previous [state = {}], [txid = {}]", state, txid);
  LOG.trace("[{}]", this);
  return state;
}
origin: prestodb/presto

/**
 * Get the object descriptor for the given address
 *
 * @param address address
 * @return object descriptor
 */
public GraphPathRecord record(long address) {
  return addresses.get(address);
}
origin: google/guava

public void testAsMapSortedReadsThrough() {
 SortedSet<String> strings = new NonNavigableSortedSet();
 Collections.addAll(strings, "one", "two", "three");
 SortedMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertNull(map.comparator());
 assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5), map);
 assertNull(map.get("four"));
 strings.add("four");
 assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5, "four", 4), map);
 assertEquals(Integer.valueOf(4), map.get("four"));
 SortedMap<String, Integer> headMap = map.headMap("two");
 assertEquals(ImmutableSortedMap.of("four", 4, "one", 3, "three", 5), headMap);
 strings.add("five");
 strings.remove("one");
 assertEquals(ImmutableSortedMap.of("five", 4, "four", 4, "three", 5), headMap);
 assertThat(map.entrySet())
   .containsExactly(
     mapEntry("five", 4), mapEntry("four", 4), mapEntry("three", 5), mapEntry("two", 3))
   .inOrder();
}
origin: google/guava

public void testFirstAndLastKeyFilteredMap() {
 SortedMap<String, Integer> unfiltered = createUnfiltered();
 unfiltered.put("apple", 2);
 unfiltered.put("banana", 6);
 unfiltered.put("cat", 3);
 unfiltered.put("dog", 5);
 SortedMap<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
 assertEquals("banana", filtered.firstKey());
 assertEquals("cat", filtered.lastKey());
}
origin: jenkinsci/jenkins

/**
 * Returns the last build.
 * @see LazyBuildMixIn#getLastBuild
 */
@Exported
@QuickSilver
public RunT getLastBuild() {
  SortedMap<Integer, ? extends RunT> runs = _getRuns();
  if (runs.isEmpty())
    return null;
  return runs.get(runs.firstKey());
}
origin: prestodb/presto

@Test
public void testBlock()
{
  for (Entry<Integer, Object> entry : expectedStackValues.entrySet()) {
    assertPositionEquals(testBlock, entry.getKey(), entry.getValue(), expectedObjectValues.get(entry.getKey()));
  }
  for (Entry<Integer, Object> entry : expectedStackValues.entrySet()) {
    assertPositionEquals(testBlockWithNulls, entry.getKey() * 2, entry.getValue(), expectedObjectValues.get(entry.getKey()));
    assertPositionEquals(testBlockWithNulls, (entry.getKey() * 2) + 1, null, null);
  }
}
java.utilSortedMap

Javadoc

A map that has its keys ordered. The sorting is according to either the natural ordering of its keys or the ordering given by a specified comparator.

Most used methods

  • put
  • get
  • entrySet
    Returns a Set view of the mappings contained in this map. The set's iterator returns the entries in
  • values
    Returns a Collection view of the values contained in this map. The collection's iterator returns the
  • keySet
    Returns a Set view of the keys contained in this map. The set's iterator returns the keys in ascendi
  • size
  • isEmpty
  • containsKey
  • remove
  • firstKey
    Returns the least key in this sorted map.
  • lastKey
    Returns the greatest key in this sorted map.
  • clear
  • lastKey,
  • clear,
  • tailMap,
  • putAll,
  • headMap,
  • subMap,
  • comparator,
  • containsValue,
  • computeIfAbsent,
  • forEach

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • Menu (java.awt)
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Reference (javax.naming)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now