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


Java SortedMap.put方法代码示例

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


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

示例1: makeMap

import java.util.SortedMap; //导入方法依赖的package包/类
private static SortedMap<String, ?> makeMap(String[] fieldNames,
                                            Object[] fieldValues) {
    if (fieldNames == null || fieldValues == null)
        throw new IllegalArgumentException("Null array parameter");
    if (fieldNames.length != fieldValues.length)
        throw new IllegalArgumentException("Different size arrays");
    SortedMap<String, Object> map =
            new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    for (int i = 0; i < fieldNames.length; i++) {
        String name = fieldNames[i];
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Empty or null field name");
        Object old = map.put(name, fieldValues[i]);
        if (old != null) {
            throw new IllegalArgumentException("Duplicate field name: " +
                                               name);
        }
    }
    return map;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ImmutableDescriptor.java

示例2: getBookmarkUrls

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Method is used internally for searching the bookmarks
 * 
 * @return
 */
private synchronized SortedMap<String, Integer> getBookmarkUrls() {
	SortedMap<String, Integer> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
	File bookmarksFile = new File(mContext.getFilesDir(), FILE_BOOKMARKS);
	try {
		BufferedReader bookmarksReader = new BufferedReader(new FileReader(bookmarksFile));
		String line;
		while ((line = bookmarksReader.readLine()) != null) {
			JSONObject object = new JSONObject(line);
			map.put(object.getString(URL), 1);
		}
		bookmarksReader.close();
	} catch (JSONException | IOException e) {
		e.printStackTrace();
	}
	return map;
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:22,代码来源:BookmarkManager.java

示例3: loadMappings

import java.util.SortedMap; //导入方法依赖的package包/类
public static SortedMap<String, ContextMapping> loadMappings(Object configuration, Version indexVersionCreated)
        throws ElasticsearchParseException {
    if (configuration instanceof Map) {
        Map<String, Object> configurations = (Map<String, Object>)configuration;
        SortedMap<String, ContextMapping> mappings = Maps.newTreeMap();
        for (Entry<String,Object> config : configurations.entrySet()) {
            String name = config.getKey();
            mappings.put(name, loadMapping(name, (Map<String, Object>) config.getValue(), indexVersionCreated));
        }
        return mappings;
    } else if (configuration == null) {
        return ContextMapping.EMPTY_MAPPING;
    } else {
        throw new ElasticsearchParseException("no valid context configuration");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:ContextBuilder.java

示例4: getDetectorGoalsMap

import java.util.SortedMap; //导入方法依赖的package包/类
private SortedMap<Integer, Goal> getDetectorGoalsMap(KafkaCruiseControlConfig config) {
  List<String> allGoals = config.getList(KafkaCruiseControlConfig.GOALS_CONFIG);
  Map<String, Integer> priorityMap = new HashMap<>();
  int i = 0;
  for (String goalClass : allGoals) {
    priorityMap.put(goalClass, i++);
  }
  List<Goal> goals = config.getConfiguredInstances(KafkaCruiseControlConfig.ANOMALY_DETECTION_GOALS_CONFIG, Goal.class);
  SortedMap<Integer, Goal> orderedGoals = new TreeMap<>();
  for (Goal goal: goals) {
    Integer priority = priorityMap.get(goal.getClass().getName());
    if (priority == null) {
      throw new IllegalArgumentException(goal.getClass().getName() + " is defined in " + KafkaCruiseControlConfig.ANOMALY_DETECTION_GOALS_CONFIG
                                             + " but not found in " + KafkaCruiseControlConfig.GOALS_CONFIG);
    }
    orderedGoals.put(priorityMap.get(goal.getClass().getName()), goal);
  }
  return orderedGoals;
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:20,代码来源:GoalViolationDetector.java

示例5: makeMap

import java.util.SortedMap; //导入方法依赖的package包/类
private static SortedMap<String, Object> makeMap(
        String[] itemNames, Object[] itemValues)
        throws OpenDataException {

    if (itemNames == null || itemValues == null)
        throw new IllegalArgumentException("Null itemNames or itemValues");
    if (itemNames.length == 0 || itemValues.length == 0)
        throw new IllegalArgumentException("Empty itemNames or itemValues");
    if (itemNames.length != itemValues.length) {
        throw new IllegalArgumentException(
                "Different lengths: itemNames[" + itemNames.length +
                "], itemValues[" + itemValues.length + "]");
    }

    SortedMap<String, Object> map = new TreeMap<String, Object>();
    for (int i = 0; i < itemNames.length; i++) {
        String name = itemNames[i];
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Null or empty item name");
        if (map.containsKey(name))
            throw new OpenDataException("Duplicate item name " + name);
        map.put(itemNames[i], itemValues[i]);
    }

    return map;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:CompositeDataSupport.java

示例6: testReadAToolbar

import java.util.SortedMap; //导入方法依赖的package包/类
public void testReadAToolbar() throws Exception {
    InputStream is = getClass().getResourceAsStream("NB_PROF634066243");
    SortedMap<Integer,InputGesture> expectedGestures = new TreeMap<Integer,InputGesture>();
    expectedGestures.put(62, InputGesture.TOOLBAR);
    expectedGestures.put(63, InputGesture.MENU);
    TestHandler records = new TestHandler(is);
    for (int cnt = 0;; cnt++) {
        LOG.log(Level.INFO, "Reading {0}th record", cnt);
        LogRecord r = records.read();
        if (r == null) {
            break;
        }
        if (r.getSequenceNumber() > expectedGestures.lastKey()) {
            break;
        }
        LOG.log(Level.INFO, "Read {0}th record, seq {1}", new Object[] { cnt, r.getSequenceNumber() });

        InputGesture g = InputGesture.valueOf(r);
        InputGesture exp = expectedGestures.get((int)r.getSequenceNumber());
        assertEquals(cnt + ": For: " + r.getSequenceNumber() + " txt:\n`"+ r.getMessage() +
            "\nkey: " + r.getResourceBundleName()
            , exp, g);
    }
    is.close();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:InputGestureTest.java

示例7: transformLettersListIntoTurn

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Returns the structure turn to be sent to the game
 *
 * @param letters           The letters to be played
 * @param startLine         The line of the first letter of the played letters
 * @param startColumn       The column of the first letter of the played letters
 * @param horizontal        True if the letters are disposed horizontally, false otherwise
 * @param checkBoardLetters True if we must check if letters have already been disposed with the given letters
 * @param board             The actual board
 *
 * @return the structure turn
 */
protected static SortedMap<BoardPosition, LetterInterface> transformLettersListIntoTurn(List<LetterInterface> letters, int startLine, int startColumn, boolean horizontal, boolean checkBoardLetters, BoardInterface board) {
    SortedMap<BoardPosition, LetterInterface> turn = new TreeMap<>();

    for (int i = 0; i < letters.size(); i++) {
        short line, column;

        if (horizontal) {
            line = (short) startLine;
            column = (short) (startColumn + i);
        } else {
            line = (short) (startLine + i);
            column = (short) startColumn;
        }

        if (line < 0 || line >= BoardInterface.BOARD_SIZE || column < 0 || column >= BoardInterface.BOARD_SIZE) {
            return null;
        }

        if (!checkBoardLetters || null == board.getLetters().get(line).get(column)) {
            turn.put(new BoardPosition(line, column), letters.get(i));
        }
    }

    return !turn.isEmpty() ? turn : null;
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:38,代码来源:PossibleTurnsFinder.java

示例8: parseTypes

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * parses a list of MappingCharFilter style rules into a custom byte[] type table
 */
static byte[] parseTypes(Collection<String> rules) {
    SortedMap<Character, Byte> typeMap = new TreeMap<>();
    for (String rule : rules) {
        Matcher m = typePattern.matcher(rule);
        if (!m.find())
            throw new RuntimeException("Invalid Mapping Rule : [" + rule + "]");
        String lhs = parseString(m.group(1).trim());
        Byte rhs = parseType(m.group(2).trim());
        if (lhs.length() != 1)
            throw new RuntimeException("Invalid Mapping Rule : [" + rule + "]. Only a single character is allowed.");
        if (rhs == null)
            throw new RuntimeException("Invalid Mapping Rule : [" + rule + "]. Illegal type.");
        typeMap.put(lhs.charAt(0), rhs);
    }

    // ensure the table is always at least as big as DEFAULT_WORD_DELIM_TABLE for performance
    byte types[] = new byte[Math.max(typeMap.lastKey() + 1, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE.length)];
    for (int i = 0; i < types.length; i++)
        types[i] = WordDelimiterIterator.getType(i);
    for (Map.Entry<Character, Byte> mapping : typeMap.entrySet())
        types[mapping.getKey()] = mapping.getValue();
    return types;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:WordDelimiterTokenFilterFactory.java

示例9: setLineMap

import java.util.SortedMap; //导入方法依赖的package包/类
private void setLineMap(Code_attribute attr) {
    SortedMap<Integer, SortedSet<Integer>> map =
            new TreeMap<Integer, SortedSet<Integer>>();
    SortedSet<Integer> allLines = new TreeSet<Integer>();
    for (Attribute a: attr.attributes) {
        if (a instanceof LineNumberTable_attribute) {
            LineNumberTable_attribute t = (LineNumberTable_attribute) a;
            for (LineNumberTable_attribute.Entry e: t.line_number_table) {
                int start_pc = e.start_pc;
                int line = e.line_number;
                SortedSet<Integer> pcLines = map.get(start_pc);
                if (pcLines == null) {
                    pcLines = new TreeSet<Integer>();
                    map.put(start_pc, pcLines);
                }
                pcLines.add(line);
                allLines.add(line);
            }
        }
    }
    lineMap = map;
    lineList = new ArrayList<Integer>(allLines);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:SourceWriter.java

示例10: parseAndValidateUpdate

import java.util.SortedMap; //导入方法依赖的package包/类
public static Map<Path, Node> parseAndValidateUpdate(Path path, Map<String, Object> update)
    throws DatabaseException {
  final SortedMap<Path, Node> parsedUpdate = new TreeMap<>();
  for (Map.Entry<String, Object> entry : update.entrySet()) {
    Path updatePath = new Path(entry.getKey());
    Object newValue = entry.getValue();
    ValidationPath.validateWithObject(path.child(updatePath), newValue);
    String childName = !updatePath.isEmpty() ? updatePath.getBack().asString() : "";
    if (childName.equals(ServerValues.NAME_SUBKEY_SERVERVALUE)
        || childName.equals("" + ".value")) {
      throw new DatabaseException(
          "Path '" + updatePath + "' contains disallowed child name: " + childName);
    }
    Node parsedValue;
    if (childName.equals(".priority")) {
      parsedValue = PriorityUtilities.parsePriority(updatePath, newValue);
    } else {
      parsedValue = NodeUtilities.NodeFromJSON(newValue);
    }
    Validation.validateWritableObject(newValue);
    parsedUpdate.put(updatePath, parsedValue);
  }
  // Check that update keys are not ancestors of each other.
  Path prevPath = null;
  for (Path curPath : parsedUpdate.keySet()) {
    // We rely on the property that sorting guarantees that ancestors come right before
    // descendants.
    hardAssert(prevPath == null || prevPath.compareTo(curPath) < 0);
    if (prevPath != null && prevPath.contains(curPath)) {
      throw new DatabaseException(
          "Path '" + prevPath + "' is an ancestor of '" + curPath + "' in an update.");
    }
    prevPath = curPath;
  }
  return parsedUpdate;
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:37,代码来源:Validation.java

示例11: queryMap

import java.util.SortedMap; //导入方法依赖的package包/类
private static SortedMap<String, String> queryMap(URL url)  {
	SortedMap<String, String> map = new TreeMap<String, String>();
    String query = url.getQuery();
    if (query == null)
    	return map;
    String[] pairs = query.split("&");
    for (String pair : pairs) {
        int idx = pair.indexOf("=");
        if (idx < 0)
	        map.put(pair, "");
        else
             map.put(pair.substring(0, idx), pair.substring(idx + 1));
    }
    return map;
}
 
开发者ID:Nexenta,项目名称:edgex-java-connector,代码行数:16,代码来源:S3Signature.java

示例12: sortResults

import java.util.SortedMap; //导入方法依赖的package包/类
private SortedMap<Long, List<SampleResult>> sortResults(List<SampleResult> list) {
    SortedMap<Long, List<SampleResult>> sortedResults = new TreeMap<>();

    for (SampleResult result : list) {
        long time = result.getEndTime() / 1000;
        if (!sortedResults.containsKey(time)) {
            sortedResults.put(time, new LinkedList<SampleResult>());
        }
        sortedResults.get(time).add(result);
    }

    return sortedResults;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:14,代码来源:LoadosophiaClient.java

示例13: makePopulatedMap

import java.util.SortedMap; //导入方法依赖的package包/类
@Override protected SortedMap<String, Integer> makePopulatedMap() {
  final SortedMap<String, Integer> sortedMap = makeEmptyMap();
  sortedMap.put("one", 1);
  sortedMap.put("two", 2);
  sortedMap.put("three", 3);
  return sortedMap;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:ForwardingSortedMapImplementsMapTest.java

示例14: translateConditions

import java.util.SortedMap; //导入方法依赖的package包/类
private Map<String, String> translateConditions(
    Map<Origin, String> refs,
    List<String> leftTable, List<String> rightTable,
    List<JoinConditionInfo> conditions) {
  SortedMap<String, String> joinConditions = new TreeMap<>();
  // translate names if needed
  for (JoinConditionInfo condition : conditions) {
    String leftColumn;
    String rightColumn;
    // figure out which is which
    if (condition.getTableAList().equals(leftTable) &&
        condition.getTableBList().equals(rightTable)) {
      leftColumn = condition.getColumnA();
      rightColumn = condition.getColumnB();
    } else if (
        condition.getTableBList().equals(leftTable) &&
        condition.getTableAList().equals(rightTable)) {
      leftColumn = condition.getColumnB();
      rightColumn = condition.getColumnA();
    } else {
      // this join condition refers a col that is not in the dataset
      return null;
    }
    String leftColumAlias = refs.get(new Origin(leftColumn, false).setTableList(leftTable));
    if (leftColumAlias != null) {
      // if this column is actually in the dataset, translate the name
      leftColumn = leftColumAlias;
    } else {
      // this join condition refers a col that is not in the dataset
      return null;
    }
    joinConditions.put(leftColumn, rightColumn);
  }
  return joinConditions;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:36,代码来源:JobsBasedRecommender.java

示例15: regroup

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * This is the function that re-groups values for a key into sub-groups based
 * on a secondary key (input tag).
 * 
 * @param arg1
 * @return
 */
private SortedMap<Object, ResetableIterator> regroup(Object key,
                                                     Iterator arg1, Reporter reporter) throws IOException {
  this.numOfValues = 0;
  SortedMap<Object, ResetableIterator> retv = new TreeMap<Object, ResetableIterator>();
  TaggedMapOutput aRecord = null;
  while (arg1.hasNext()) {
    this.numOfValues += 1;
    if (this.numOfValues % 100 == 0) {
      reporter.setStatus("key: " + key.toString() + " numOfValues: "
                         + this.numOfValues);
    }
    if (this.numOfValues > this.maxNumOfValuesPerGroup) {
      continue;
    }
    aRecord = ((TaggedMapOutput) arg1.next()).clone(job);
    Text tag = aRecord.getTag();
    ResetableIterator data = retv.get(tag);
    if (data == null) {
      data = createResetableIterator();
      retv.put(tag, data);
    }
    data.add(aRecord);
  }
  if (this.numOfValues > this.largestNumOfValues) {
    this.largestNumOfValues = numOfValues;
    LOG.info("key: " + key.toString() + " this.largestNumOfValues: "
             + this.largestNumOfValues);
  }
  return retv;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:DataJoinReducerBase.java


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