Guava ImmutableSortedMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ImmutableSortedMap class.

This code example shows how to use the following methods:get, entrySet, size
    public void testImmutableSortedMap( ObjectMapperTester<ImmutableSortedMap<Integer, Boolean>> mapper ) {
        String json = mapper.write( ImmutableSortedMap.of( 12, true, 4, false ) );
        assertEquals( "{\"4\":false,\"12\":true}", json );
 
        ImmutableSortedMap<Integer, Boolean> map = mapper.read( "{\"12\":true,\"4\":false}" );
        assertEquals( 2, map.size() );
        assertEquals( Boolean.TRUE, map.get( Integer.valueOf( 12 ) ) );
        assertEquals( Boolean.FALSE, map.get( Integer.valueOf( 4 ) ) );
 
        Iterator<Entry<Integer, Boolean>> iterator = map.entrySet().iterator();
 
        Entry<Integer, Boolean> entry = iterator.next();
        assertEquals( Integer.valueOf( 4 ), entry.getKey() );
        assertFalse( entry.getValue() );
 
        entry = iterator.next();
        assertEquals( Integer.valueOf( 12 ), entry.getKey() );
        assertTrue( entry.getValue() );
    } 
 
6
CodeRank
This code example shows how to use the following methods:get
This code example shows how to use the following methods:containsValue
        return m_map.get().containsKey(key);
    } 
 
    @Override 
    public boolean containsValue(Object value) { 
        return m_map.get().containsValue(value);
    } 
 
    @Override 
    public V get(Object key) { 
        return m_map.get().get(key);
    } 
 
    @Override 
    public V put(K key, V value) {
        while (true) { 
            ImmutableSortedMap<K, V> original = m_map.get();
            Builder<K, V> builder = ImmutableSortedMap.<K, V>naturalOrder();
            V oldValue = null;
            boolean replaced = false;
4
CodeRank
See Code Examples for Guava ImmutableSortedMap Methods: