java.util.TreeMap.values()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中java.util.TreeMap.values()方法的一些代码示例,展示了TreeMap.values()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.values()方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:values

TreeMap.values介绍

[英]Returns a Collection view of the values contained in this map. The collection's iterator returns the values in ascending order of the corresponding keys. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
[中]返回此映射中包含的值的集合视图。集合的迭代器按相应键的升序返回值。集合由映射支持,因此对映射的更改将反映在集合中,反之亦然。如果在集合上进行迭代时修改映射(除了通过迭代器自己的删除操作),则迭代的结果是未定义的。集合支持元素移除,通过迭代器从映射中移除相应的映射。移除、收集。移除、移除所有、保留和清除操作。它不支持添加或添加所有操作。

代码示例

代码示例来源:origin: hankcs/HanLP

/**
 * 获取前几个关键句子
 *
 * @param size 要几个
 * @return 关键句子的下标
 */
public int[] getTopSentence(int size)
{
  Collection<Integer> values = top.values();
  size = Math.min(size, values.size());
  int[] indexArray = new int[size];
  Iterator<Integer> it = values.iterator();
  for (int i = 0; i < size; ++i)
  {
    indexArray[i] = it.next();
  }
  return indexArray;
}

代码示例来源:origin: org.apache.poi/poi

/**
 * @return an iterator of the PHYSICAL rows.  Meaning the 3rd element may not
 *         be the third row if say for instance the second row is undefined.
 *         Call getRowNum() on each row if you care which one it is.
 */
@Override
public Iterator<Row> rowIterator() {
  @SuppressWarnings("unchecked") // can this clumsy generic syntax be improved?
      Iterator<Row> result = (Iterator<Row>) (Iterator<? extends Row>) _rows.values().iterator();
  return result;
}

代码示例来源:origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public List<TypeDescription> getNamedTypes() {
  List<TypeDescription> namedTypes = new ArrayList<TypeDescription>(this.namedTypes.size());
  for (TypeDefinition typeDefinition : this.namedTypes.values()) {
    namedTypes.add(typeDefinition.asErasure());
  }
  return namedTypes;
}

代码示例来源:origin: wildfly/wildfly

void print(StringBuilder sb, int indent) {
  printIndent(sb, indent);
  sb.append(SEPARATOR).append(name);
  if(children != null && !children.isEmpty()) {
    Collection values=children.values();
    for(Iterator it=values.iterator(); it.hasNext();) {
      sb.append('\n');
      ((Node)it.next()).print(sb, indent + INDENT);
    }
  }
}

代码示例来源:origin: apache/geode

@Override
public boolean hasNext() {
 boolean result;
 if (this.subIt != null) {
  result = this.subIt.hasNext();
  if (!result) {
   this.subIt = null;
  } else {
   return result;
  }
 }
 result = this.it.hasNext();
 if (this.usingIt && !result) {
  this.usingIt = false;
  this.it = this.diskMap.values().iterator();
  result = this.it.hasNext();
 }
 return result;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

this.shortLengths.put(i, edge);
    } else {
      this.lengths.put(i, edge);
  int si = this.lengths.size();
            this.shortLengths.put(eB.getId(), eB);
          } else {
            this.lengths.put(eB.getId(), eB);
            this.lengths.put(eC.getId(), eC);
for (Edge e : this.lengths.values()) {
  LineString l = e.getGeometry().toGeometry(this.geomFactory);
  edges.add(l);
LineString merge = (LineString)lineMerger.getMergedLineStrings().iterator().next();

代码示例来源:origin: robolectric/robolectric

final TypeElement type = c.iterator().next();
   referentMap.put(type, referents.getKey());
  } else {
shadowTypes.values().forEach(shadowInfo -> shadowInfo.prepare(referentResolver, helpers));
resetterMap.values().forEach(resetterInfo -> resetterInfo.prepare(referentResolver));

代码示例来源:origin: apache/ignite

/**
 * @throws IgniteCheckedException If failed.
 */
@Test
public void testFind() throws IgniteCheckedException {
  TestTree tree = createTestTree(true);
  TreeMap<Long, Long> map = new TreeMap<>();
  long size = CNT * CNT;
  for (long i = 1; i <= size; i++) {
    tree.put(i);
    map.put(i, i);
  }
  checkCursor(tree.find(null, null), map.values().iterator());
  checkCursor(tree.find(10L, 70L), map.subMap(10L, true, 70L, true).values().iterator());
}

代码示例来源:origin: scouter-project/scouter

private static URL[] getURLs(String path) throws IOException {
    TreeMap<String, File> jars = new TreeMap<String, File>();
    File[] files = new File(path).listFiles();
    for (int i = 0; files != null && i < files.length; i++) {
      if (files[i].getName().startsWith("."))
        continue;
      jars.put(files[i].getName(), files[i]);
    }

    URL[] urls = new URL[jars.size()];
    ArrayList<File> v = new ArrayList<File>(jars.values());
    for (int i = 0; i < urls.length; i++) {
      urls[i] = v.get(i).toURI().toURL();
    }
    return urls;
  }
}

代码示例来源:origin: apache/ignite

/** This method generates "random double, integer" pairs, sort them, gets first "testSize" elements and returns appropriate indices */
@NotNull private TreeSet<Integer> getSortedIndices(int datasetSize, int testSize) {
  Random rnd = new Random();
  TreeMap<Double, Integer> randomIdxPairs = new TreeMap<>();
  for (int i = 0; i < datasetSize; i++)
    randomIdxPairs.put(rnd.nextDouble(), i);
  final TreeMap<Double, Integer> testIdxPairs = randomIdxPairs.entrySet().stream()
    .limit(testSize)
    .collect(TreeMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), Map::putAll);
  return new TreeSet<>(testIdxPairs.values());
}

代码示例来源:origin: Codecademy/EventHub

int pointersSizeInBytes = 2 * sortedProperties.size() * RECORD_SIZE_IN_BYTES;
byte[] bytes = new byte[META_DATA_SIZE_IN_BYTES + pointersSizeInBytes + propertiesSizeInBytes];
byteBuffer.putInt(sortedProperties.size());
for (String value : sortedProperties.values()) {
 propertiesBuffer.put(value.getBytes());
 byteBuffer.putInt(propertiesBuffer.position());

代码示例来源:origin: stackoverflow.com

//create TreeMap instance
 TreeMap treeMap = new TreeMap();
 //add key value pairs to TreeMap
 treeMap.put("1","One");
 treeMap.put("2","Two");
 treeMap.put("3","Three");
 /*
  get Collection of values contained in TreeMap using
  Collection values()        
 */
 Collection c = treeMap.values();
 //obtain an Iterator for Collection
 Iterator itr = c.iterator();
 //iterate through TreeMap values iterator
 while(itr.hasNext())
  System.out.println(itr.next());

代码示例来源:origin: ankidroid/Anki-Android

for (long id : children(did).values()) {
      rem(id, cardsToo);
    for (long id : children(did).values()) {
      rem(id, cardsToo);
select(mDecks.keySet().iterator().next());

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Get this collection's iterator.
 */
public Iterator<PackageRelationship> iterator() {
  return relationshipsByID.values().iterator();
}

代码示例来源:origin: apache/ignite

map.put(i, i);
map.values().iterator());

代码示例来源:origin: scouter-project/scouter

private static URL[] getURLs(String path) throws IOException {
    TreeMap<String, File> jars = new TreeMap<String, File>();
    File[] files = new File(path).listFiles();
    for (int i = 0; files != null && i < files.length; i++) {
      if (files[i].getName().startsWith("."))
        continue;
      jars.put(files[i].getName(), files[i]);
    }

    URL[] urls = new URL[jars.size()];
    ArrayList<File> v = new ArrayList<File>(jars.values());
    for (int i = 0; i < urls.length; i++) {
      urls[i] = v.get(i).toURI().toURL();
    }
    return urls;
  }
}

代码示例来源:origin: apache/storm

private static String getGroupName(Group g) {
  TreeMap<Integer, String> sortedNames = new TreeMap<>();
  for (Node n : g.nodes) {
    if (n.name != null) {
      sortedNames.put(n.creationIndex, n.name);
    }
  }
  List<String> names = new ArrayList<>();
  String prevName = null;
  for (String n : sortedNames.values()) {
    if (prevName == null || !n.equals(prevName)) {
      prevName = n;
      names.add(n);
    }
  }
  return Utils.join(names, "-");
}

代码示例来源:origin: hankcs/HanLP

@Override
public int build(TreeMap<String, V> keyValueMap)
{
  int size = keyValueMap.size();
  int[] indexArray = new int[size];
  valueArray = (V[]) keyValueMap.values().toArray();
  List<String> keyList = new ArrayList<String>(size);
  int i = 0;
  for (Entry<String, V> entry : keyValueMap.entrySet())
  {
    indexArray[i] = i;
    valueArray[i] = entry.getValue();
    keyList.add(entry.getKey());
    ++i;
  }
  build(keyList, indexArray);
  return 0;
}

代码示例来源:origin: wildfly/wildfly

private void cancelGoAwayStreams(int lastStreamId, long errorCode, ByteBuf debugData) {
  Iterator<PendingStream> iter = pendingStreams.values().iterator();
  Exception e = new Http2GoAwayException(lastStreamId, errorCode, ByteBufUtil.getBytes(debugData));
  while (iter.hasNext()) {
    PendingStream stream = iter.next();
    if (stream.streamId > lastStreamId) {
      iter.remove();
      stream.close(e);
    }
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 *  Returns an iterator of the physical rows
 *
 * @return an iterator of the PHYSICAL rows.  Meaning the 3rd element may not
 * be the third row if say for instance the second row is undefined.
 */
@Override
public Iterator<Row> rowIterator()
{
  @SuppressWarnings("unchecked")
  Iterator<Row> result = (Iterator<Row>)(Iterator<? extends Row>)_rows.values().iterator();
  return result;
}

相关文章