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


Java SortedSet.iterator方法代碼示例

本文整理匯總了Java中java.util.SortedSet.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java SortedSet.iterator方法的具體用法?Java SortedSet.iterator怎麽用?Java SortedSet.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.SortedSet的用法示例。


在下文中一共展示了SortedSet.iterator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: normalMessages

import java.util.SortedSet; //導入方法依賴的package包/類
private static String normalMessages(AutomaticDependencies.Report rep) {
    SortedSet<String> s = new TreeSet<String>(); // Set<String>
    Iterator it = rep.getMessages().iterator();
    while (it.hasNext()) {
        s.add((String)it.next());
    }
    StringBuilder b = new StringBuilder();
    it = s.iterator();
    while (it.hasNext()) {
        b.append(it.next());
        if (it.hasNext()) {
            b.append(", ");
        }
    }
    return b.toString();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:AutomaticDependenciesTest.java

示例2: testHeadSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * headSet returns set with keys in requested range
 */
public void testHeadSetContents() {
    NavigableSet set = set5();
    SortedSet sm = set.headSet(four);
    assertTrue(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(four, set.first());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:TreeSubSetTest.java

示例3: testHeadSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * headSet returns set with keys in requested range
 */
public void testHeadSetContents() {
    TreeSet set = set5();
    SortedSet sm = set.headSet(four);
    assertTrue(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(four, set.first());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:TreeSetTest.java

示例4: testDescendingHeadSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * headSet returns set with keys in requested range
 */
public void testDescendingHeadSetContents() {
    NavigableSet set = dset5();
    SortedSet sm = set.headSet(m4);
    assertTrue(sm.contains(m1));
    assertTrue(sm.contains(m2));
    assertTrue(sm.contains(m3));
    assertFalse(sm.contains(m4));
    assertFalse(sm.contains(m5));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(m4, set.first());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:TreeSubSetTest.java

示例5: handleAttributesSubtree

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * Returns the Attr[]s to be output for the given element.
 * <br>
 * The code of this method is a copy of {@link #handleAttributes(Element,
 * NameSpaceSymbTable)},
 * whereas it takes into account that subtree-c14n is -- well -- subtree-based.
 * So if the element in question isRoot of c14n, it's parent is not in the
 * node set, as well as all other ancestors.
 *
 * @param element
 * @param ns
 * @return the Attr[]s to be output
 * @throws CanonicalizationException
 */
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
    throws CanonicalizationException {
    if (!element.hasAttributes()) {
        return null;
    }

    // result will contain all the attrs declared directly on that element
    final SortedSet<Attr> result = this.result;
    result.clear();

    if (element.hasAttributes()) {
        NamedNodeMap attrs = element.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr attribute = (Attr) attrs.item(i);
            result.add(attribute);
        }
    }

    return result.iterator();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:38,代碼來源:CanonicalizerPhysical.java

示例6: buildFloatGlobalDictionary

import java.util.SortedSet; //導入方法依賴的package包/類
private static VectorContainer buildFloatGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) {
  final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null);
  final VectorContainer input = new VectorContainer(bufferAllocator);
  final NullableFloat4Vector floatVector = input.addOrGet(field);
  floatVector.allocateNew();
  SortedSet<Float> values = Sets.newTreeSet();
  for (Dictionary dictionary : dictionaries) {
    for (int i = 0; i <= dictionary.getMaxId(); ++i) {
      values.add(dictionary.decodeToFloat(i));
    }
  }
  if (existingDict != null) {
    final NullableFloat4Vector existingDictValues = existingDict.getValueAccessorById(NullableFloat4Vector.class, 0).getValueVector();
    for (int i = 0; i < existingDict.getRecordCount(); ++i) {
      values.add(existingDictValues.getAccessor().get(i));
    }
  }
  final Iterator<Float> iter = values.iterator();
  int recordCount = 0;
  while (iter.hasNext()) {
    floatVector.getMutator().setSafe(recordCount++, iter.next());
  }
  floatVector.getMutator().setValueCount(recordCount);
  input.setRecordCount(recordCount);
  input.buildSchema(BatchSchema.SelectionVectorMode.NONE);
  return input;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:28,代碼來源:GlobalDictionaryBuilder.java

示例7: testDescendingTailSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * tailSet returns set with keys in requested range
 */
public void testDescendingTailSetContents() {
    NavigableSet set = dset5();
    SortedSet sm = set.tailSet(m2);
    assertFalse(sm.contains(m1));
    assertTrue(sm.contains(m2));
    assertTrue(sm.contains(m3));
    assertTrue(sm.contains(m4));
    assertTrue(sm.contains(m5));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    k = (Integer)(i.next());
    assertEquals(m4, k);
    k = (Integer)(i.next());
    assertEquals(m5, k);
    assertFalse(i.hasNext());

    SortedSet ssm = sm.tailSet(m4);
    assertEquals(m4, ssm.first());
    assertEquals(m5, ssm.last());
    assertTrue(ssm.remove(m4));
    assertEquals(1, ssm.size());
    assertEquals(3, sm.size());
    assertEquals(4, set.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:TreeSubSetTest.java

示例8: buildDoubleGlobalDictionary

import java.util.SortedSet; //導入方法依賴的package包/類
private static VectorContainer buildDoubleGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) {
  final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE), null);
  final VectorContainer input = new VectorContainer(bufferAllocator);
  final NullableFloat8Vector doubleVector = input.addOrGet(field);
  doubleVector.allocateNew();
  SortedSet<Double> values = Sets.newTreeSet();
  for (Dictionary dictionary : dictionaries) {
    for (int i = 0; i <= dictionary.getMaxId(); ++i) {
      values.add(dictionary.decodeToDouble(i));
    }
  }
  if (existingDict != null) {
    final NullableFloat8Vector existingDictValues = existingDict.getValueAccessorById(NullableFloat8Vector.class, 0).getValueVector();
    for (int i = 0; i < existingDict.getRecordCount(); ++i) {
      values.add(existingDictValues.getAccessor().get(i));
    }
  }
  final Iterator<Double> iter = values.iterator();
  int recordCount = 0;
  while (iter.hasNext()) {
    doubleVector.getMutator().setSafe(recordCount++, iter.next());
  }
  doubleVector.getMutator().setValueCount(recordCount);
  input.setRecordCount(recordCount);
  input.buildSchema(BatchSchema.SelectionVectorMode.NONE);
  return input;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:28,代碼來源:GlobalDictionaryBuilder.java

示例9: getSoleGroupForBranch

import java.util.SortedSet; //導入方法依賴的package包/類
/**
    * For chosen and tool based branching, we expect there to be only one group per branch, so get the single group. If
    * there is more than one group, put out a warning and return the first group for this sequence activity, related
    * via the BranchEntries
    */
   public Group getSoleGroupForBranch() {

SortedSet<Group> groups = getGroupsForBranch();
if (groups.size() > 1) {
    log.warn("Branch " + this + " has more than one group. This is unexpected. Using only the first group.");
}
Iterator iter = groups.iterator();
if (iter.hasNext()) {
    return (Group) iter.next();
}

return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:SequenceActivity.java

示例10: testTailSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * tailSet returns set with keys in requested range
 */
public void testTailSetContents() {
    TreeSet set = set5();
    SortedSet sm = set.tailSet(two);
    assertFalse(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertTrue(sm.contains(four));
    assertTrue(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    k = (Integer)(i.next());
    assertEquals(four, k);
    k = (Integer)(i.next());
    assertEquals(five, k);
    assertFalse(i.hasNext());

    SortedSet ssm = sm.tailSet(four);
    assertEquals(four, ssm.first());
    assertEquals(five, ssm.last());
    assertTrue(ssm.remove(four));
    assertEquals(1, ssm.size());
    assertEquals(3, sm.size());
    assertEquals(4, set.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:TreeSetTest.java

示例11: testSortAndDedupByteRefArray

import java.util.SortedSet; //導入方法依賴的package包/類
public void testSortAndDedupByteRefArray() {
    SortedSet<BytesRef> set = new TreeSet<>();
    final int numValues = scaledRandomIntBetween(0, 10000);
    List<BytesRef> tmpList = new ArrayList<>();
    BytesRefArray array = new BytesRefArray(Counter.newCounter());
    for (int i = 0; i < numValues; i++) {
        String s = randomRealisticUnicodeOfCodepointLengthBetween(1, 100);
        set.add(new BytesRef(s));
        tmpList.add(new BytesRef(s));
        array.append(new BytesRef(s));
    }
    if (randomBoolean()) {
        Collections.shuffle(tmpList, random());
        for (BytesRef ref : tmpList) {
            array.append(ref);
        }
    }
    int[] indices = new int[array.size()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = i;
    }
    int numUnique = CollectionUtils.sortAndDedup(array, indices);
    assertThat(numUnique, equalTo(set.size()));
    Iterator<BytesRef> iterator = set.iterator();

    BytesRefBuilder spare = new BytesRefBuilder();
    for (int i = 0; i < numUnique; i++) {
        assertThat(iterator.hasNext(), is(true));
        assertThat(array.get(spare, indices[i]), equalTo(iterator.next()));
    }

}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:33,代碼來源:CollectionUtilsTests.java

示例12: testSubSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * subSet returns set with keys in requested range
 */
public void testSubSetContents() {
    TreeSet set = set5();
    SortedSet sm = set.subSet(two, four);
    assertEquals(two, sm.first());
    assertEquals(three, sm.last());
    assertEquals(2, sm.size());
    assertFalse(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    Iterator j = sm.iterator();
    j.next();
    j.remove();
    assertFalse(set.contains(two));
    assertEquals(4, set.size());
    assertEquals(1, sm.size());
    assertEquals(three, sm.first());
    assertEquals(three, sm.last());
    assertTrue(sm.remove(three));
    assertTrue(sm.isEmpty());
    assertEquals(3, set.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:TreeSetTest.java

示例13: object2CanonicalString

import java.util.SortedSet; //導入方法依賴的package包/類
private static void object2CanonicalString(JsonNode node, StringBuilder builder) {
    builder.append('{');
    if (node.size() > 0) {
        final SortedSet<String> sortedFieldNames = new TreeSet<>();
        node.fieldNames().forEachRemaining(sortedFieldNames::add);
        Iterator<String> sortedNameIterator = sortedFieldNames.iterator();
        appendField(node, sortedNameIterator.next(), builder);
        while (sortedNameIterator.hasNext()) {
            builder.append(',');
            appendField(node, sortedNameIterator.next(), builder);
        }
    }
    builder.append('}');
}
 
開發者ID:mgrand,項目名稱:bigchaindb-java-driver,代碼行數:15,代碼來源:JsonCanonicalizer.java

示例14: canonicalizeLocators

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * Canonicalizes a locators string so that they may be compared.
 * 
 * @since GemFire 4.0
 */
private static String canonicalizeLocators(String locators) {
  SortedSet sorted = new TreeSet();
  StringTokenizer st = new StringTokenizer(locators, ",");
  while (st.hasMoreTokens()) {
    String l = st.nextToken();
    StringBuffer canonical = new StringBuffer();
    DistributionLocatorId locId = new DistributionLocatorId(l);
    String addr = locId.getBindAddress();
    if (addr != null && addr.trim().length() > 0) {
      canonical.append(addr);
    } else {
      canonical.append(locId.getHost().getHostAddress());
    }
    canonical.append("[");
    canonical.append(String.valueOf(locId.getPort()));
    canonical.append("]");
    sorted.add(canonical.toString());
  }

  StringBuffer sb = new StringBuffer();
  for (Iterator iter = sorted.iterator(); iter.hasNext();) {
    sb.append((String) iter.next());
    if (iter.hasNext()) {
      sb.append(",");
    }
  }
  return sb.toString();
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:34,代碼來源:InternalDistributedSystem.java

示例15: testDescendingSubSetContents

import java.util.SortedSet; //導入方法依賴的package包/類
/**
 * subSet returns set with keys in requested range
 */
public void testDescendingSubSetContents() {
    NavigableSet set = dset5();
    SortedSet sm = set.subSet(m2, m4);
    assertEquals(m2, sm.first());
    assertEquals(m3, sm.last());
    assertEquals(2, sm.size());
    assertFalse(sm.contains(m1));
    assertTrue(sm.contains(m2));
    assertTrue(sm.contains(m3));
    assertFalse(sm.contains(m4));
    assertFalse(sm.contains(m5));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    Iterator j = sm.iterator();
    j.next();
    j.remove();
    assertFalse(set.contains(m2));
    assertEquals(4, set.size());
    assertEquals(1, sm.size());
    assertEquals(m3, sm.first());
    assertEquals(m3, sm.last());
    assertTrue(sm.remove(m3));
    assertTrue(sm.isEmpty());
    assertEquals(3, set.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:ConcurrentSkipListSubSetTest.java


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