当前位置: 首页>>代码示例>>Java>>正文


Java NavigableMap.put方法代码示例

本文整理汇总了Java中java.util.NavigableMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableMap.put方法的具体用法?Java NavigableMap.put怎么用?Java NavigableMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.NavigableMap的用法示例。


在下文中一共展示了NavigableMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPollLastEntry

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * pollLastEntry returns entries in order
 */
public void testPollLastEntry() {
    NavigableMap map = map5();
    Map.Entry e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(four, e.getKey());
    map.put(five, "E");
    e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(three, e.getKey());
    map.remove(two);
    e = map.pollLastEntry();
    assertEquals(one, e.getKey());
    try {
        e.setValue("E");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollLastEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TreeSubMapTest.java

示例2: getFamilyMap

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * Map of qualifiers to values.
 * <p>
 * Returns a Map of the form: <code>Map&lt;qualifier,value&gt;</code>
 * @param family column family to get
 * @return map of qualifiers to values
 */
public NavigableMap<byte[], byte[]> getFamilyMap(byte [] family) {
  if(this.familyMap == null) {
    getMap();
  }
  if(isEmpty()) {
    return null;
  }
  NavigableMap<byte[], byte[]> returnMap =
    new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
  NavigableMap<byte[], NavigableMap<Long, byte[]>> qualifierMap =
    familyMap.get(family);
  if(qualifierMap == null) {
    return returnMap;
  }
  for(Map.Entry<byte[], NavigableMap<Long, byte[]>> entry :
    qualifierMap.entrySet()) {
    byte [] value =
      entry.getValue().get(entry.getValue().firstKey());
    returnMap.put(entry.getKey(), value);
  }
  return returnMap;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:Result.java

示例3: put

import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public synchronized <T> void put(T array, Class<T> arrayClass) {
  ArrayAdapterInterface<T> arrayAdapter = getAdapterFromType(arrayClass);
  int size = arrayAdapter.getArrayLength(array);
  int arrayBytes = size * arrayAdapter.getElementSizeInBytes();
  if (!isSmallEnoughForReuse(arrayBytes)) {
    return;
  }
  Key key = keyPool.get(size, arrayClass);

  groupedMap.put(key, array);
  NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass);
  Integer current = sizes.get(key.size);
  sizes.put(key.size, current == null ? 1 : current + 1);
  currentSize += arrayBytes;
  evict();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:LruArrayPool.java

示例4: testRangesByUpperBound

import java.util.NavigableMap; //导入方法依赖的package包/类
public void testRangesByUpperBound() {
  for (Range<Integer> range1 : QUERY_RANGES) {
    for (Range<Integer> range2 : QUERY_RANGES) {
      TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
      rangeSet.add(range1);
      rangeSet.add(range2);

      NavigableMap<Cut<Integer>, Range<Integer>> expectedRangesByUpperBound = Maps.newTreeMap();
      for (Range<Integer> range : rangeSet.asRanges()) {
        expectedRangesByUpperBound.put(range.upperBound, range);
      }
      testNavigationAgainstExpected(expectedRangesByUpperBound,
          new TreeRangeSet.RangesByUpperBound<Integer>(rangeSet.rangesByLowerBound),
          CUTS_TO_TEST);
    }
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:TreeRangeSetTest.java

示例5: getNoVersionMap

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * Map of families to their most recent qualifiers and values.
 * <p>
 * Returns a two level Map of the form: <code>Map&amp;family,Map&lt;qualifier,value&gt;&gt;</code>
 * <p>
 * The most recent version of each qualifier will be used.
 * @return map from families to qualifiers and value
 */
public NavigableMap<byte[], NavigableMap<byte[], byte[]>> getNoVersionMap() {
  if(this.familyMap == null) {
    getMap();
  }
  if(isEmpty()) {
    return null;
  }
  NavigableMap<byte[], NavigableMap<byte[], byte[]>> returnMap =
    new TreeMap<byte[], NavigableMap<byte[], byte[]>>(Bytes.BYTES_COMPARATOR);
  for(Map.Entry<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>
    familyEntry : familyMap.entrySet()) {
    NavigableMap<byte[], byte[]> qualifierMap =
      new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
    for(Map.Entry<byte[], NavigableMap<Long, byte[]>> qualifierEntry :
      familyEntry.getValue().entrySet()) {
      byte [] value =
        qualifierEntry.getValue().get(qualifierEntry.getValue().firstKey());
      qualifierMap.put(qualifierEntry.getKey(), value);
    }
    returnMap.put(familyEntry.getKey(), qualifierMap);
  }
  return returnMap;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:Result.java

示例6: put

import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public synchronized <T> void put(T array) {
  @SuppressWarnings("unchecked")
  Class<T> arrayClass = (Class<T>) array.getClass();

  ArrayAdapterInterface<T> arrayAdapter = getAdapterFromType(arrayClass);
  int size = arrayAdapter.getArrayLength(array);
  int arrayBytes = size * arrayAdapter.getElementSizeInBytes();
  if (!isSmallEnoughForReuse(arrayBytes)) {
    return;
  }
  Key key = keyPool.get(size, arrayClass);

  groupedMap.put(key, array);
  NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass);
  Integer current = sizes.get(key.size);
  sizes.put(key.size, current == null ? 1 : current + 1);
  currentSize += arrayBytes;
  evict();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:LruArrayPool.java

示例7: getDatabeansByEntityKey

import java.util.NavigableMap; //导入方法依赖的package包/类
public static <EK extends EntityKey<EK>,
	PK extends EntityPrimaryKey<EK,PK>,
	D extends Databean<PK,D>>
NavigableMap<EK,List<D>> getDatabeansByEntityKey(Iterable<D> databeans){
	NavigableMap<EK,List<D>> databeansByEntityKey = new TreeMap<>();
	for(D databean : IterableTool.nullSafe(databeans)){
		if(databean == null){
			continue;
		}// seem to be getting some null entries from TraceFlushController?
		PK pk = databean.getKey();//leave on individual line for NPE trace
		EK ek = pk.getEntityKey();
		List<D> databeansForEntity = databeansByEntityKey.get(ek);
		if(databeansForEntity == null){
			databeansForEntity = new ArrayList<>();
			databeansByEntityKey.put(ek, databeansForEntity);
		}
		databeansForEntity.add(databean);
	}
	return databeansByEntityKey;
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:21,代码来源:EntityTool.java

示例8: incrementCounter

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * Helper function for {@link #coalesceIncrements} to increment a counter
 * value in the passed data structure.
 *
 * @param counters  Nested data structure containing the counters.
 * @param row       Row key to increment.
 * @param family    Column family to increment.
 * @param qualifier Column qualifier to increment.
 * @param count     Amount to increment by.
 */
private void incrementCounter(
    Map<byte[], Map<byte[], NavigableMap<byte[], Long>>> counters,
    byte[] row, byte[] family, byte[] qualifier, Long count) {

  Map<byte[], NavigableMap<byte[], Long>> families = counters.get(row);
  if (families == null) {
    families = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
    counters.put(row, families);
  }

  NavigableMap<byte[], Long> qualifiers = families.get(family);
  if (qualifiers == null) {
    qualifiers = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
    families.put(family, qualifiers);
  }

  Long existingValue = qualifiers.get(qualifier);
  if (existingValue == null) {
    qualifiers.put(qualifier, count);
  } else {
    qualifiers.put(qualifier, existingValue + count);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:34,代码来源:HBaseSink.java

示例9: provideVersions

import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
protected NavigableMap<String, ZoneRules> provideVersions(String zoneId) {
    NavigableMap<String, ZoneRules> result = new TreeMap<>();
    result.put("DynamicVersion1", BASE);
    if (count > 2) {
        result.put("DynamicVersion2", ALTERNATE);
    }
    return result;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKZoneRulesProvider.java

示例10: main

import java.util.NavigableMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    
    NavigableMap<Integer, String> nm = new ConcurrentSkipListMap<>();
    
    // add some elements        
    nm.put(4, "Wednesday");
    nm.put(5, "Thursday");
    nm.put(6, "Friday");
    nm.put(1, "Sunday");
    nm.put(2, "Monday");                       
    System.out.println("Add some elements. Content: " + nm.toString());
    
    // get key 5
    System.out.println("Get key 5 : " + nm.get(5));
    
    // ceilingkey & floorkey
    System.out.println("CeilingKey 3 : " + nm.ceilingKey(3));
    System.out.println("FloorKey 3 : " + nm.floorKey(3));
    
    // ceilingentry & floorentry
    System.out.println("CeilingEntry 3 : " + nm.ceilingEntry(3));
    System.out.println("FloorEntry 4 : " + nm.floorEntry(4));
    
    // higherEtntry & lowerEntry
    System.out.println("HigherEntry 4 : " + nm.higherEntry(4));
    System.out.println("HigherEntry 3 : " + nm.higherEntry(3));
    System.out.println("LowerEntry 4 : " + nm.lowerEntry(4));
    
    // firstEntry & lastEntry
    System.out.println("FirstEntry : " + nm.firstEntry());
    System.out.println("LastEntry : "+nm.lastEntry());                
}
 
开发者ID:mkdika,项目名称:learnjava8,代码行数:33,代码来源:TestNavigableMap.java

示例11: testAssignmentManagerTruncatedList

import java.util.NavigableMap; //导入方法依赖的package包/类
@Test
public void testAssignmentManagerTruncatedList() throws IOException {
  AssignmentManager am = Mockito.mock(AssignmentManager.class);
  RegionStates rs = Mockito.mock(RegionStates.class);

  // Add 100 regions as in-transition
  NavigableMap<String, RegionState> regionsInTransition =
    Maps.newTreeMap();
  for (byte i = 0; i < 100; i++) {
    HRegionInfo hri = new HRegionInfo(FAKE_TABLE.getTableName(),
        new byte[]{i}, new byte[]{(byte) (i+1)});
    regionsInTransition.put(hri.getEncodedName(),
      new RegionState(hri, RegionState.State.CLOSING, 12345L, FAKE_HOST));
  }
  // Add hbase:meta in transition as well
  regionsInTransition.put(
      HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(),
      new RegionState(HRegionInfo.FIRST_META_REGIONINFO,
                      RegionState.State.CLOSING, 12345L, FAKE_HOST));
  Mockito.doReturn(rs).when(am).getRegionStates();
  Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();

  // Render to a string
  StringWriter sw = new StringWriter();
  new AssignmentManagerStatusTmpl()
    .setLimit(50)
    .render(sw, am);
  String result = sw.toString();

  // Should always include META
  assertTrue(result.contains(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()));

  // Make sure we only see 50 of them
  Matcher matcher = Pattern.compile("CLOSING").matcher(result);
  int count = 0;
  while (matcher.find()) {
    count++;
  }
  assertEquals(50, count);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:TestMasterStatusServlet.java

示例12: testStandardLastEntry

import java.util.NavigableMap; //导入方法依赖的package包/类
public void testStandardLastEntry() {
  NavigableMap<String, Integer> forwarding =
      new StandardLastEntryForwardingNavigableMap<String, Integer>(
          new SafeTreeMap<String, Integer>());
  assertNull(forwarding.lastEntry());
  forwarding.put("b", 2);
  assertEquals(immutableEntry("b", 2), forwarding.lastEntry());
  forwarding.put("c", 3);
  assertEquals(immutableEntry("c", 3), forwarding.lastEntry());
  forwarding.put("a", 1);
  assertEquals(immutableEntry("c", 3), forwarding.lastEntry());
  forwarding.remove("c");
  assertEquals(immutableEntry("b", 2), forwarding.lastEntry());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:15,代码来源:ForwardingNavigableMapTest.java

示例13: testRangesByLowerBounds

import java.util.NavigableMap; //导入方法依赖的package包/类
private void testRangesByLowerBounds(
    TreeRangeSet<Integer> rangeSet, Iterable<Range<Integer>> expectedRanges) {
  NavigableMap<Cut<Integer>, Range<Integer>> expectedRangesByLowerBound = Maps.newTreeMap();
  for (Range<Integer> range : expectedRanges) {
    expectedRangesByLowerBound.put(range.lowerBound, range);
  }

  NavigableMap<Cut<Integer>, Range<Integer>> rangesByLowerBound = rangeSet.rangesByLowerBound;
  testNavigationAgainstExpected(expectedRangesByLowerBound, rangesByLowerBound, CUTS_TO_TEST);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:TreeRangeSetTest.java

示例14: testDescendingPut1_NullPointerException

import java.util.NavigableMap; //导入方法依赖的package包/类
/**
 * put(null,x) throws NPE
 */
public void testDescendingPut1_NullPointerException() {
    NavigableMap c = dmap5();
    try {
        c.put(null, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TreeSubMapTest.java

示例15: put

import java.util.NavigableMap; //导入方法依赖的package包/类
void put(NavigableMap<Integer, Integer> map, int key) {
    if (map.put(key, 2 * key) == null)
        bs.set(key);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ConcurrentSkipListMapTest.java


注:本文中的java.util.NavigableMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。