當前位置: 首頁>>代碼示例>>Java>>正文


Java SortedMap.keySet方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:MalformedSurrogates.java

示例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;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:LamsCoreToolService.java

示例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());
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:26,代碼來源:ParameterMappingsSet.java

示例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;
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:19,代碼來源:CharsetsShellCommand.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:21,代碼來源:TreeMapTest.java

示例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;
}
 
開發者ID:androidthings,項目名稱:sample-tensorflow-imageclassifier,代碼行數:24,代碼來源:TtsSpeaker.java

示例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;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:19,代碼來源:TransformManager.java

示例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;
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:37,代碼來源:Validation.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:PublicPackagesPanel.java

示例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());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:SpliteratorCharacteristics.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:DataTransferer.java

示例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);
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:14,代碼來源:CollectionUtil.java

示例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;
}
 
開發者ID:Chrisp1tv,項目名稱:ScrabbleGame,代碼行數:17,代碼來源:PlayedTurnValidityChecker.java

示例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);
  }
}
 
開發者ID:kenahrens,項目名稱:newrelic-api-client-java,代碼行數:15,代碼來源:Transform.java

示例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
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:35,代碼來源:TestTableStatistics.java


注:本文中的java.util.SortedMap.keySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。