本文整理汇总了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();
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
示例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()));
}
}
示例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());
}
示例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('}');
}
示例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();
}
示例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());
}