當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。