本文整理匯總了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);
}
示例2: getFamilyMap
import java.util.NavigableMap; //導入方法依賴的package包/類
/**
* Map of qualifiers to values.
* <p>
* Returns a Map of the form: <code>Map<qualifier,value></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;
}
示例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();
}
示例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);
}
}
}
示例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&family,Map<qualifier,value>></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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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) {}
}
示例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);
}