本文整理了Java中java.util.TreeMap.keySet()
方法的一些代码示例,展示了TreeMap.keySet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.keySet()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:keySet
[英]Returns a Set view of the keys contained in this map. The set's iterator returns the keys in ascending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clearoperations. It does not support the add or addAlloperations.
[中]返回此映射中包含的键的集合视图。集合的迭代器按升序返回键。集合由映射支持,因此对映射的更改将反映在集合中,反之亦然。如果在对集合进行迭代时修改映射(通过迭代器自己的移除操作除外),则迭代的结果是未定义的。该集合支持元素移除,即通过迭代器从映射中移除相应的映射。移除,设置。移除、移除所有、保留和清除操作。它不支持add或addAlloperations。
代码示例来源:origin: TooTallNate/Java-WebSocket
@Override
public Iterator<String> iterateHttpFields() {
return Collections.unmodifiableSet( map.keySet() ).iterator();// Safety first
}
代码示例来源:origin: deathmarine/Luyten
private void warmUpWithFirstLink() {
if (selectionToUniqueStrTreeMap.keySet().size() > 0) {
Selection selection = selectionToUniqueStrTreeMap.keySet().iterator().next();
getLinkDescriptionForOffset(selection.from);
}
}
代码示例来源:origin: apache/avro
@Override
public ArrayList<String> getBucketLabels() {
ArrayList<String> outArray = new ArrayList<>(index.keySet().size());
Iterator<String> bucketsIt = this.getBuckets();
while (bucketsIt.hasNext()) {
outArray.add(bucketsIt.next());
}
return outArray;
}
代码示例来源:origin: com.h2database/h2
@Override
public void truncate(long size) {
writeCount.incrementAndGet();
if (size == 0) {
fileSize = 0;
memory.clear();
return;
}
fileSize = size;
for (Iterator<Long> it = memory.keySet().iterator(); it.hasNext();) {
long pos = it.next();
if (pos < size) {
break;
}
ByteBuffer buff = memory.get(pos);
if (buff.capacity() > size) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_READING_FAILED,
"Could not truncate to {0}; " +
"partial truncate is not supported", pos);
}
it.remove();
}
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
for (QuadEdge qe : qeSorted.keySet()) {
LineSegment s = qe.toLineSegment();
s.normalize();
this.shortLengths.put(i, edge);
} else {
this.lengths.put(i, edge);
this.shortLengths.put(eB.getId(), eB);
} else {
this.lengths.put(eB.getId(), eB);
this.lengths.put(eC.getId(), eC);
LineString merge = (LineString)lineMerger.getMergedLineStrings().iterator().next();
代码示例来源:origin: apache/ignite
map.put(i, i);
Collections.<Long>emptyList().iterator());
checkCursor(tree.find(null, null, new TestTreeFindFilteredClosure(map.keySet()), null),
map.values().iterator());
Collections.singleton(val).iterator());
代码示例来源:origin: hankcs/HanLP
for (Synonym synonym : synonymList)
Set<Long> idSet = treeMap.get(synonym.realWord);
if (idSet == null)
treeMap.put(synonym.realWord, idSet);
for (String key : treeMap.keySet())
代码示例来源:origin: ankidroid/Anki-Android
/**
* Sync handling
* ***********************************************************
*/
public void beforeUpload() {
for (String k : mTags.keySet()) {
mTags.put(k, 0);
}
save();
}
代码示例来源:origin: JetBrains/ideavim
for (Character code : keys.keySet()) {
String key = keys.get(code);
代码示例来源:origin: sannies/mp4parser
public V get(Object k) {
if (!(k instanceof Comparable)) {
return null;
}
Comparable<K> key = (Comparable<K>) k;
if (isEmpty()) {
return null;
}
Iterator<K> keys = base.keySet().iterator();
K a = keys.next();
do {
if (keys.hasNext()) {
if (key.compareTo(a) < 0) {
a = keys.next();
} else {
return base.get(a);
}
} else {
return base.get(a);
}
} while (true);
}
代码示例来源:origin: hankcs/HanLP
private int getValueIndex(MDAGNode currentNode)
{
MDAGNode targetNode = currentNode.transition(DELIMITER);
if (targetNode == null) return -1;
// 接下来应该是一条单链路
TreeMap<Character, MDAGNode> outgoingTransitions = targetNode.getOutgoingTransitions();
assert outgoingTransitions.size() == 1 : "不是单链!";
char high = outgoingTransitions.keySet().iterator().next();
targetNode = targetNode.transition(high);
outgoingTransitions = targetNode.getOutgoingTransitions();
assert outgoingTransitions.size() == 1 : "不是单链!";
char low = outgoingTransitions.keySet().iterator().next();
return ByteUtil.convertTwoCharToInt(high, low);
}
代码示例来源:origin: stanfordnlp/CoreNLP
for(Integer i : words.keySet()){
if(i >= numIterationsOfSavedPatternsToLoad){
System.out.println("Removing patterns from iteration " + i);
TwoDimensionalCounter<CandidatePhrase, E> wordsandLemmaPatExtracted = new TwoDimensionalCounter<>();
Set<CandidatePhrase> alreadyLabeledWords = new HashSet<>();
while(sentsIter.hasNext()){
Pair<Map<String, DataInstance>, File> sents = sentsIter.next();
if(labelSentsUsingModel){
Redwood.log(Redwood.DBG, "labeling sentences from " + sents.second() + " with the already learned words");
代码示例来源:origin: kevin-wayne/algs4
/**
* Returns all of the keys in this symbol table.
* To iterate over all of the keys in a symbol table named {@code st}, use the
* foreach notation: {@code for (Key key : st)}.
* <p>
* This method is provided for backward compatibility with the version from
* <em>Introduction to Programming in Java: An Interdisciplinary Approach.</em>
*
* @return an iterator to all of the keys in this symbol table
* @deprecated Replaced by {@link #keys()}.
*/
@Deprecated
public Iterator<Key> iterator() {
return st.keySet().iterator();
}
代码示例来源:origin: aragozin/jvm-tools
private void printObjs(List<Long> changedIds, List<Long> oldDomIds, List<Long> newDomIds, List<Boolean> addedByDirtySet, List<Long> changedIdx) {
if (changedIds.size()>20) return;
TreeMap<Integer,String> m = new TreeMap();
for (int i=0; i<changedIds.size(); i++) {
Long iid = changedIds.get(i);
Long oldDom = oldDomIds.get(i);
Long newDom = newDomIds.get(i);
Long index = changedIdx.get(i);
Boolean addedByDirt = addedByDirtySet.get(i);
Instance ii = heap.getInstanceByID(iid.longValue());
int number = ii.getInstanceNumber();
String text = "Index: "+index+(addedByDirt?" New ":" Old ")+printInstance(iid);
text+=" OldDom "+printInstance(oldDom);
text+=" NewDom: "+printInstance(newDom);
m.put(number,text);
}
for (Integer in : m.keySet()) {
System.out.println(m.get(in));
}
}
代码示例来源:origin: apache/storm
LOG.debug("supervisorsWithFailures : {}", supervisorsWithFailures);
reporter.reportBlacklist(supervisor, supervisorsWithFailures);
blacklist.put(supervisor, resumeTime / nimbusMonitorFreqSecs);
Set<String> toRelease = releaseBlacklistWhenNeeded(cluster, new ArrayList<>(blacklist.keySet()));
if (toRelease != null) {
LOG.debug("Releasing {} nodes because of low resources", toRelease.size());
return blacklist.keySet();
代码示例来源:origin: apache/storm
private void processBatchInsert(TreeMap<RocksDbKey, RocksDbValue> batchMap) throws MetricException {
try (WriteBatch writeBatch = new WriteBatch()) {
// take the batched metric data and write to the database
for (RocksDbKey k : batchMap.keySet()) {
RocksDbValue v = batchMap.get(k);
writeBatch.put(k.getRaw(), v.getRaw());
}
store.db.write(writeOpts, writeBatch);
} catch (Exception e) {
String message = "Failed to store data to RocksDB";
LOG.error(message, e);
throw new MetricException(message, e);
}
}
代码示例来源:origin: sannies/mp4parser
public V remove(Object k) {
if (!(k instanceof Comparable)) {
return null;
}
Comparable<K> key = (Comparable<K>) k;
if (isEmpty()) {
return null;
}
Iterator<K> keys = base.keySet().iterator();
K a = keys.next();
do {
if (keys.hasNext()) {
if (key.compareTo(a) < 0) {
a = keys.next();
} else {
return base.remove(a);
}
} else {
return base.remove(a);
}
} while (true);
}
代码示例来源:origin: apache/avro
@Override
public Iterator<String> getBuckets() {
return new Iterator<String>() {
Iterator<T> it = index.keySet().iterator();
T cur = it.next(); // there's always at least one element
int pos = 0;
@Override
public boolean hasNext() {
return (pos < index.keySet().size());
}
@Override
public String next() {
pos = pos + 1;
T left = cur;
cur = it.hasNext() ? it.next() : null;
return rangeAsString(left, cur);
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public Iterator<String> iterator() {
return Collections.unmodifiableSet(fields.keySet()).iterator();
}
代码示例来源:origin: Netflix/EVCache
| ((long) (digest[1 + h * 4] & 0xFF) << 8)
| (digest[h * 4] & 0xFF);
newNodeMap.put(Long.valueOf(k), node);
if (log.isDebugEnabled()) log.debug("Key : " + hashString + " ; hash : " + k + "; node " + node );
for (int i = 0; i < numReps; i++) {
final Long hashL = Long.valueOf(hashingAlgorithm.hash(config.getKeyForNode(node, i)));
newNodeMap.put(hashL, node);
for (Long key : newNodeMap.keySet()) {
log.trace("Hash : " + key + "; Node : " + newNodeMap.get(key));
内容来源于网络,如有侵权,请联系作者删除!