本文整理匯總了Java中java.util.TreeMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeMap.put方法的具體用法?Java TreeMap.put怎麽用?Java TreeMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.TreeMap
的用法示例。
在下文中一共展示了TreeMap.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: UploadCdnEntity
import java.util.TreeMap; //導入方法依賴的package包/類
public String UploadCdnEntity(TreeMap<String, Object> params) throws NoSuchAlgorithmException, IOException {
String actionName = "UploadCdnEntity";
String entityFile = params.get("entityFile").toString();
params.remove("entityFile");
File file = new File(entityFile);
if (!file.exists()) {
throw new FileNotFoundException();
}
if (!params.containsKey("entityFileMd5")) {
params.put("entityFileMd5", MD5.fileNameToMD5(entityFile));
}
return call(actionName, params, entityFile);
}
示例2: printRow
import java.util.TreeMap; //導入方法依賴的package包/類
private void printRow(TRowResult rowResult) {
// copy values into a TreeMap to get them in sorted order
TreeMap<String, TCell> sorted = new TreeMap<String, TCell>();
for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) {
sorted.put(utf8(column.getKey().array()), column.getValue());
}
StringBuilder rowStr = new StringBuilder();
for (SortedMap.Entry<String, TCell> entry : sorted.entrySet()) {
rowStr.append(entry.getKey());
rowStr.append(" => ");
rowStr.append(utf8(entry.getValue().value.array()));
rowStr.append("; ");
}
System.out.println("row: " + utf8(rowResult.row.array()) + ", cols: " + rowStr);
}
示例3: testCombMNZ
import java.util.TreeMap; //導入方法依賴的package包/類
/**
* Test combMNZ.
*/
@Test
public void testCombMNZ() {
final RankAggregation borda = RankAggregation.build("combMNZ", maxRank);
borda.computeUserRanking(runs, userID, allItems, ranking);
final TreeMap<Double, LongSet> userRanking = new TreeMap<Double, LongSet>();
userRanking.put(12.0, HashLongSets.newUpdatableSet(new long[] { 3 }));
userRanking.put(10.0, HashLongSets.newUpdatableSet(new long[] { 1 }));
userRanking.put(5.0, HashLongSets.newUpdatableSet(new long[] { 2 }));
userRanking.put(2.0, HashLongSets.newUpdatableSet(new long[] { 4 }));
Assert.assertEquals(userRanking, ranking);
}
示例4: addNotificationSocket
import java.util.TreeMap; //導入方法依賴的package包/類
private void addNotificationSocket(final TreeMap<Integer, Entry> entries,
FdSet fdSet) {
entries.put(notificationSockets[1].fd,
new Entry(notificationSockets[1], new NotificationHandler()));
try {
notificationSockets[1].refCount.reference();
} catch (IOException e) {
throw new RuntimeException(e);
}
fdSet.add(notificationSockets[1].fd);
if (LOG.isTraceEnabled()) {
LOG.trace(this + ": adding notificationSocket " +
notificationSockets[1].fd + ", connected to " +
notificationSockets[0].fd);
}
}
示例5: createAllDisplayOrderOutputs
import java.util.TreeMap; //導入方法依賴的package包/類
/**
* Check the display order embedded in the condition name. The name MUST start with
* OUTPUT_NAME_NOMINATION_SELECTION.
*/
private TreeMap<String, ToolOutput> createAllDisplayOrderOutputs(ITaskListService taskListService,
Long toolSessionId, Long learnerId) {
TreeMap<String, ToolOutput> output = null;
int num = taskListService.getNumTasksCompletedByUser(toolSessionId, learnerId);
ToolOutput toolOutput = new ToolOutput(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED,
getI18NText(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, true), new Long(num));
output.put(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, toolOutput);
String i18nDescription = getI18NText(OUTPUT_NAME_TOOL_CONDITION, true);
TaskList taskList = taskListService.getTaskListBySessionId(toolSessionId);
Set<TaskListCondition> conditions = taskList.getConditions();
for (TaskListCondition condition : conditions) {
String name = buildConditionName(OUTPUT_NAME_TOOL_CONDITION, condition.getName());
boolean check = taskListService.checkCondition(condition.getName(), toolSessionId, learnerId);
output.put(name, new ToolOutput(name, i18nDescription, check));
}
return output;
}
示例6: getAllFieldsMutable
import java.util.TreeMap; //導入方法依賴的package包/類
/** Internal helper which returns a mutable map. */
private Map<FieldDescriptor, Object> getAllFieldsMutable() {
final TreeMap<FieldDescriptor, Object> result =
new TreeMap<FieldDescriptor, Object>();
final Descriptor descriptor = internalGetFieldAccessorTable().descriptor;
for (final FieldDescriptor field : descriptor.getFields()) {
if (field.isRepeated()) {
final List value = (List) getField(field);
if (!value.isEmpty()) {
result.put(field, value);
}
} else {
if (hasField(field)) {
result.put(field, getField(field));
}
}
}
return result;
}
示例7: handleRequest
import java.util.TreeMap; //導入方法依賴的package包/類
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
boolean decodeDone = exchange.getConnection().getUndertowOptions().get(UndertowOptions.DECODE_URL, true);
if (!decodeDone) {
final StringBuilder sb = new StringBuilder();
final boolean decodeSlash = exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALLOW_ENCODED_SLASH, false);
exchange.setRequestPath(URLUtils.decode(exchange.getRequestPath(), charset, decodeSlash, sb));
exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, sb));
exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, sb));
if (!exchange.getQueryString().isEmpty()) {
final TreeMap<String, Deque<String>> newParams = new TreeMap<>();
for (Map.Entry<String, Deque<String>> param : exchange.getQueryParameters().entrySet()) {
final Deque<String> newVales = new ArrayDeque<>(param.getValue().size());
for (String val : param.getValue()) {
newVales.add(URLUtils.decode(val, charset, true, sb));
}
newParams.put(URLUtils.decode(param.getKey(), charset, true, sb), newVales);
}
exchange.getQueryParameters().clear();
exchange.getQueryParameters().putAll(newParams);
}
}
next.handleRequest(exchange);
}
示例8: OrganizationDictionary
import java.util.TreeMap; //導入方法依賴的package包/類
@Inject
public OrganizationDictionary(NTDictionary dictionary, Environment environment) throws IOException {
this.dictionary = dictionary;
long start = System.currentTimeMillis();
MynlpResource resource = environment.loadResource("org.dict.tr", "inner://dictionary/organization/nt.tr.txt");
//轉移矩陣
transformMatrixDictionary = new EnumTransformMatrix<>(resource);
// AC tree
{
TreeMap<String, String> map = new TreeMap<>();
for (String pattern : NTPattern.patterns) {
map.put(pattern, pattern);
}
AhoCoraickDoubleArrayTrieBuilder<String> acdaBuilder = new AhoCoraickDoubleArrayTrieBuilder<>();
this.trie = acdaBuilder.build(map);
}
logger.info("PlaceDictionary 加載成功,耗時" + (System.currentTimeMillis() - start) + "ms");
}
示例9: load
import java.util.TreeMap; //導入方法依賴的package包/類
public boolean load(ByteArray byteArray)
{
idToLabelMap = new String[byteArray.nextInt()];
TreeMap<String, Integer> map = new TreeMap<String, Integer>();
for (int i = 0; i < idToLabelMap.length; i++)
{
idToLabelMap[i] = byteArray.nextString();
map.put(idToLabelMap[i], i);
}
return trie.build(map) == 0;
}
示例10: testPutAllGlobalLock
import java.util.TreeMap; //導入方法依賴的package包/類
@Test
public void testPutAllGlobalLock() throws Exception {
TreeMap trialMap = new TreeMap();
for (long i = 0; i < 1000; i++) {
trialMap.put(new Long(i), new Long(i));
}
testRegion.putAll(trialMap);
ThreadUtils.join(this.thread, 30 * 1000);
assertTrue(this.testOK);
}
示例11: buildIndexes
import java.util.TreeMap; //導入方法依賴的package包/類
private TreeMap<String, Integer> buildIndexes(Map<String, List<String>> passwordsByLetter) {
TreeMap<String, Integer> baseIndexes = Maps.newTreeMap();
int indexSum = 0;
for (List<String> currList : passwordsByLetter.values()) {
String firstLetter = extractFirstWordsFirstLetter(currList);
baseIndexes.put(firstLetter, indexSum);
indexSum += currList.size();
}
return baseIndexes;
}
示例12: intToRoman
import java.util.TreeMap; //導入方法依賴的package包/類
public String intToRoman(int num) {
TreeMap<Integer, String> map = new TreeMap<>();
map.put(1000, "M");
map.put(900, "CM");
map.put(500, "D");
map.put(400, "CD");
map.put(100, "C");
map.put(90, "XC");
map.put(50, "L");
map.put(40, "XL");
map.put(10, "X");
map.put(9, "IX");
map.put(5, "V");
map.put(4, "IV");
map.put(1, "I");
StringBuilder result = new StringBuilder();
while (num > 0) {
int key = map.floorKey(num);
result.append(map.get(key));
num -= key;
}
return result.toString();
}
示例13: shiftRight
import java.util.TreeMap; //導入方法依賴的package包/類
@Override
public ArrayData shiftRight(final int by) {
final TreeMap<Long, Object> newSparseMap = new TreeMap<>();
// Move elements from underlying to sparse map if necessary
final long len = underlying.length();
if (len + by > maxDenseLength) {
// Length of underlying array after shrinking, before right-shifting
final long tempLength = Math.max(0, maxDenseLength - by);
for (long i = tempLength; i < len; i++) {
if (underlying.has((int) i)) {
newSparseMap.put(i + by, underlying.getObject((int) i));
}
}
underlying = underlying.shrink((int) tempLength);
underlying.setLength(tempLength);
}
underlying = underlying.shiftRight(by);
for (final Map.Entry<Long, Object> entry : sparseMap.entrySet()) {
final long newIndex = entry.getKey() + by;
newSparseMap.put(newIndex, entry.getValue());
}
sparseMap = newSparseMap;
setLength(length() + by);
return this;
}
示例14: getResourceRoots
import java.util.TreeMap; //導入方法依賴的package包/類
TreeMap<String, String> getResourceRoots() {
TreeMap<String, String> roots = new TreeMap<String, String>();
if (mfmSettings.get(MFM_Constants.ROMS_FULL_SET_DIRECTORY) != null) {
roots.put(MFM_Constants.ROMS_FULL_SET_DIRECTORY,
(String) mfmSettings.get(MFM_Constants.ROMS_FULL_SET_DIRECTORY));
}
if (mfmSettings.get(MFM_Constants.CHDS_FULL_SET_DIRECTORY) != null) {
roots.put(MFM_Constants.CHDS_FULL_SET_DIRECTORY,
(String) mfmSettings.get(MFM_Constants.CHDS_FULL_SET_DIRECTORY));
}
if (mfmSettings.get(MFM_Constants.SOFTWARELIST_ROMS_FULL_SET_DIRECTORY) != null) {
roots.put(MFM_Constants.SOFTWARELIST_ROMS_FULL_SET_DIRECTORY,
(String) mfmSettings.get(MFM_Constants.SOFTWARELIST_ROMS_FULL_SET_DIRECTORY));
}
if (mfmSettings.get(MFM_Constants.SOFTWARELIST_CHDS_FULL_SET_DIRECTORY) != null) {
roots.put(MFM_Constants.SOFTWARELIST_CHDS_FULL_SET_DIRECTORY,
(String) mfmSettings.get(MFM_Constants.SOFTWARELIST_CHDS_FULL_SET_DIRECTORY));
}
if (mfmSettings.get(MFM_Constants.EXTRAS_FULL_SET_DIRECTORY) != null) {
roots.put(MFM_Constants.EXTRAS_FULL_SET_DIRECTORY,
(String) mfmSettings.get(MFM_Constants.EXTRAS_FULL_SET_DIRECTORY));
}
if (mfmSettings.get(MFM_Constants.MAME_VIDS_DIRECTORY) != null) {
roots.put(MFM_Constants.MAME_VIDS_DIRECTORY,
(String) mfmSettings.get(MFM_Constants.MAME_VIDS_DIRECTORY));
}
return roots;
}
示例15: insertMap
import java.util.TreeMap; //導入方法依賴的package包/類
public TreeMap<String,String> insertMap(){
TreeMap<String, String> maps = new TreeMap<>();
for (int i = 0 ; i < 10;i++) {
maps.put(i + "", 10 * i + "");
}
return maps;
}