本文整理汇总了Java中java.util.SortedMap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java SortedMap.keySet方法的具体用法?Java SortedMap.keySet怎么用?Java SortedMap.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SortedMap
的用法示例。
在下文中一共展示了SortedMap.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.util.SortedMap; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
SortedMap<String, Charset> map = Charset.availableCharsets();
for (String name : map.keySet()) {
Charset charset = map.get(name);
if (charset.canEncode() && !charset.name().equals("x-COMPOUND_TEXT")) {
testNormalSurrogate(charset, NORMAL_SURROGATE);
testMalformedSurrogate(charset, MALFORMED_SURROGATE);
testMalformedSurrogate(charset, REVERSED_SURROGATE);
testMalformedSurrogate(charset, SOLITARY_HIGH_SURROGATE);
testMalformedSurrogate(charset, SOLITARY_LOW_SURROGATE);
testSurrogateWithReplacement(charset, NORMAL_SURROGATE);
testSurrogateWithReplacement(charset, MALFORMED_SURROGATE);
testSurrogateWithReplacement(charset, REVERSED_SURROGATE);
testSurrogateWithReplacement(charset, SOLITARY_HIGH_SURROGATE);
testSurrogateWithReplacement(charset, SOLITARY_LOW_SURROGATE);
}
}
}
示例2: getActivityMaxPossibleMark
import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public Long getActivityMaxPossibleMark(ToolActivity activity) {
// if ActivityEvaluation is not set it means activity will produce no toolOutputs and thus max possible mark is null
if ((activity == null) || (activity.getEvaluation() == null)) {
return null;
}
// the first available activity evaluation will be the only one that activity has
ActivityEvaluation evaluation = activity.getEvaluation();
// searching for the according toolOutputDefinition
SortedMap<String, ToolOutputDefinition> toolOutputDefinitions = getOutputDefinitionsFromTool(
activity.getToolContentId(), ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION);
for (String key : toolOutputDefinitions.keySet()) {
ToolOutputDefinition toolOutputDefinition = toolOutputDefinitions.get(key);
if (evaluation.getToolOutputDefinition().equals(key)) {
Object upperLimit = toolOutputDefinition.getEndValue();
if ((upperLimit != null) && (upperLimit instanceof Long)) {
return (Long) upperLimit;
}
break;
}
}
return null;
}
示例3: debug
import java.util.SortedMap; //导入方法依赖的package包/类
public String debug(Collection<Statement> catalog_stmts) {
StringBuilder sb = new StringBuilder();
for (Statement catalog_stmt : catalog_stmts) {
if (this.stmtIndex.containsKey(catalog_stmt)) {
int num_instances = this.stmtIndex.get(catalog_stmt).size();
sb.append(catalog_stmt.getName() + " [# of Instances=" + num_instances + "]\n");
for (Integer catalog_stmt_index : this.stmtIndex.get(catalog_stmt).keySet()) {
if (num_instances > 1) sb.append(String.format(" Instance #%02d:\n", catalog_stmt_index));
if (this.stmtIndex.get(catalog_stmt).containsKey(catalog_stmt_index)) {
SortedMap<StmtParameter, SortedSet<ParameterMapping>> params = this.stmtIndex.get(catalog_stmt).get(catalog_stmt_index);
for (StmtParameter catalog_stmt_param : params.keySet()) {
for (ParameterMapping c : params.get(catalog_stmt_param)) {
sb.append(" " + c + "\n");
} // FOR (correlation)
} // FOR (catalog_stmt_param)
} else {
sb.append(" <NONE>\n");
}
} // FOR (catalog_stmt_index)
sb.append(StringUtil.SINGLE_LINE);
}
} // FOR (catalot_stmt)
return (sb.toString());
}
示例4: executeCommand
import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public ShellStatus executeCommand(IEnvironment env, String arguments) {
try {
if (!arguments.equals("")) {
env.writeln("Invalid number of arguments for charsets command");
return ShellStatus.CONTINUE;
}
SortedMap<String, Charset> charsets = Charset.availableCharsets();
for (String charset : charsets.keySet()) {
env.writeln(charset);
}
} catch (Exception e) {
System.out.println("Unexpected error with command charsets!");
}
return ShellStatus.CONTINUE;
}
示例5: stressMapChecked
import java.util.SortedMap; //导入方法依赖的package包/类
public void stressMapChecked(SortedMap<Integer,Integer> map)
{
// get the keys, remove every odd element, and re-add it
Set<Integer> keyset = map.keySet();
Object[] keys = keyset.toArray();
// remove every odd element
for (int i=1; i<keys.length; i=i+2)
{
map.remove(keys[i]);
}
assertEquals((keys.length+1)/2, map.size());
// re-add every odd element
for (int i=0; i<keys.length; i++)
{
map.put((Integer)keys[i], null);
}
// just check that we have the same number of keys
assertEquals(map.size(), keys.length);
}
示例6: playJoke
import java.util.SortedMap; //导入方法依赖的package包/类
private boolean playJoke(TextToSpeech tts) {
long now = System.currentTimeMillis();
// choose a random joke whose last occurrence was far enough in the past
SortedMap<Long, Utterance> availableJokes = mJokes.headMap(now - JOKE_COOLDOWN_MILLIS);
Utterance joke = null;
if (!availableJokes.isEmpty()) {
int r = RANDOM.nextInt(availableJokes.size());
int i = 0;
for (Long key : availableJokes.keySet()) {
if (i++ == r) {
joke = availableJokes.remove(key); // also removes from mJokes
break;
}
}
}
if (joke != null) {
joke.speak(tts);
// add it back with the current time
mJokes.put(now, joke);
return true;
}
return false;
}
示例7: findTransformTaskByTransformType
import java.util.SortedMap; //导入方法依赖的package包/类
public static List<TransformTask> findTransformTaskByTransformType(AppVariantContext appVariantContext, Class<?>
transformClass) {
List<TransformTask> transformTasksList = Lists.newArrayList();
VariantConfiguration config = appVariantContext.getVariantConfiguration();
TaskCollection<TransformTask> transformTasks = appVariantContext.getProject().getTasks().withType(
TransformTask.class);
SortedMap<String, TransformTask> transformTaskSortedMap = transformTasks.getAsMap();
String variantName = config.getFullName();
for (String taskName : transformTaskSortedMap.keySet()) {
TransformTask transformTask = transformTaskSortedMap.get(taskName);
if (variantName == transformTask.getVariantName()) {
if (transformTask.getTransform().getClass() == transformClass) {
transformTasksList.add(transformTask);
}
}
}
return transformTasksList;
}
示例8: 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;
}
示例9: getPublicPackagesForPlugin
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* Transforms public packages in form of "selected items" map into
* set of strings describing public packages in maven-nbm-plugin syntax.
*/
public static SortedSet<String> getPublicPackagesForPlugin (SortedMap<String, Boolean> selItems) {
SortedSet<String> result = new TreeSet<String>();
Set<String> processed = new HashSet<String>();
for (Entry<String, Boolean> entry : selItems.entrySet()) {
if (entry.getValue() && !processed.contains(entry.getKey())) {
boolean allSubpackages = true;
Set<String> processedCandidates = new HashSet<String>();
String prefix = entry.getKey() + ".";
for (String key : selItems.keySet()) {
if (key.startsWith(prefix)) {
if (selItems.get(key)) {
processedCandidates.add(key);
} else {
allSubpackages = false;
break;
}
}
}
if (allSubpackages && processedCandidates.size() > COALESCE_LIMIT) {
result.add(entry.getKey() + ALL_SUBPACKAGES);
processed.addAll(processedCandidates);
} else {
result.add(entry.getKey());
}
}
}
return result;
}
示例10: assertSortedMapCharacteristics
import java.util.SortedMap; //导入方法依赖的package包/类
void assertSortedMapCharacteristics(SortedMap<Integer, String> m, int keyCharacteristics) {
assertMapCharacteristics(m, keyCharacteristics, Spliterator.SORTED);
Set<Integer> keys = m.keySet();
if (m.comparator() != null) {
assertNotNullComparator(keys);
}
else {
assertNullComparator(keys);
}
assertISEComparator(m.values());
assertNotNullComparator(m.entrySet());
}
示例11: keysToLongArray
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* Helper function to reduce a Map with Long keys to a long array.
* <p>
* The map keys are sorted according to the native formats preference
* order.
*/
public static long[] keysToLongArray(SortedMap map) {
Set keySet = map.keySet();
long[] retval = new long[keySet.size()];
int i = 0;
for (Iterator iter = keySet.iterator(); iter.hasNext(); i++) {
retval[i] = ((Long)iter.next()).longValue();
}
return retval;
}
示例12: getSortedList
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* @param <K>
* @param <V>
* @param map
* @return
*/
public static <K extends Comparable<?>, V> List<V> getSortedList(SortedMap<K, Collection<V>> map) {
List<V> ret = new ArrayList<V>();
for (K key : map.keySet()) {
ret.addAll(map.get(key));
} // FOR
return (ret);
}
示例13: allLettersArePlayedOnTheBoard
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* Checks whether the played letters have been played on the board
*
* @param playedLetters The letters played in the current turn
*
* @return true if the letters have been played on the board, false otherwise
*/
protected static boolean allLettersArePlayedOnTheBoard(SortedMap<BoardPosition, LetterInterface> playedLetters) {
for (BoardPosition boardPosition : playedLetters.keySet()) {
if (boardPosition.getLine() < 0 || boardPosition.getLine() >= BoardInterface.BOARD_SIZE || boardPosition.getColumn() < 0 || boardPosition.getColumn() >= BoardInterface.BOARD_SIZE) {
return false;
}
}
return true;
}
示例14: processMetric
import java.util.SortedMap; //导入方法依赖的package包/类
private void processMetric(Application app, Metric metric) {
// This is the timestamp of the latest event
// only process timeslices more recent than this
Date latest = latestMap.get(metric);
// ArrayList<Timeslice> tsList = metric.getTimeslicesSince(latest);
SortedMap<Date, Timeslice> tsMap = metric.getTimeslicesSince(latest);
// Make an event per timeslice
// for (Timeslice ts : tsList) {
for (Date date : tsMap.keySet()) {
Timeslice ts = tsMap.get(date);
processTimeslice(app, metric, ts);
}
}
示例15: testFromJSONString
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* testFromJSONString
*/
@SuppressWarnings("unchecked")
public void testFromJSONString() throws Exception {
String json = stats.toJSONString();
assertNotNull(json);
JSONObject jsonObject = new JSONObject(json);
TableStatistics copy = new TableStatistics(catalog_tbl);
copy.fromJSONObject(jsonObject, catalog_db);
for (TableStatistics.Members element : TableStatistics.Members.values()) {
String field_name = element.toString().toLowerCase();
Field field = TableStatistics.class.getDeclaredField(field_name);
assertNotNull(field);
Object orig_value = field.get(stats);
Object copy_value = field.get(copy);
if (orig_value instanceof SortedMap) {
SortedMap orig_map = (SortedMap)orig_value;
SortedMap copy_map = (SortedMap)copy_value;
for (Object key : orig_map.keySet()) {
assertTrue(copy_map.containsKey(key));
Object orig_map_value = orig_map.get(key);
if (! (orig_map_value instanceof ColumnStatistics)) {
assertEquals(orig_map_value, copy_map.get(key));
}
} // FOR
} else {
assertEquals(orig_value, copy_value);
}
} // FOR
}