本文整理了Java中java.util.SortedSet.iterator()
方法的一些代码示例,展示了SortedSet.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SortedSet.iterator()
方法的具体详情如下:
包路径:java.util.SortedSet
类名称:SortedSet
方法名:iterator
暂无
代码示例来源:origin: google/j2objc
@Override
public K firstKey() {
// correctly throws NoSuchElementException when filtered map is empty.
return keySet().iterator().next();
}
代码示例来源:origin: remkop/picocli
private void compactImports() {
Iterator<TypeName> i = imports.iterator();
while (i.hasNext()) {
TypeName importName = i.next();
if (!importName.getSimpleName().equals("*") && registeredPackages.contains(importName.getPackageName())) {
i.remove();
}
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Compare the two conditions based on the URL patterns they contain.
* Patterns are compared one at a time, from top to bottom. If all compared
* patterns match equally, but one instance has more patterns, it is
* considered a closer match.
* <p>It is assumed that both instances have been obtained via
* {@link #getMatchingCondition(ServerWebExchange)} to ensure they
* contain only patterns that match the request and are sorted with
* the best matches on top.
*/
@Override
public int compareTo(PatternsRequestCondition other, ServerWebExchange exchange) {
Iterator<PathPattern> iterator = this.patterns.iterator();
Iterator<PathPattern> iteratorOther = other.getPatterns().iterator();
while (iterator.hasNext() && iteratorOther.hasNext()) {
int result = PathPattern.SPECIFICITY_COMPARATOR.compare(iterator.next(), iteratorOther.next());
if (result != 0) {
return result;
}
}
if (iterator.hasNext()) {
return -1;
}
else if (iteratorOther.hasNext()) {
return 1;
}
else {
return 0;
}
}
代码示例来源:origin: apache/kylin
public static ArrayList<Range<Integer>> buildRanges(SortedSet<Integer> values) {
ArrayList<Range<Integer>> ranges = Lists.newArrayList();
if (values == null || values.isEmpty())
return ranges;
Iterator<Integer> iter = values.iterator();
int lastBegin = iter.next();
int lastEnd = lastBegin;
int temp = 0;
for (int index = 1; index < values.size(); index++) {
temp = iter.next();
if (temp - lastEnd != 1) {
ranges.add(Range.closed(lastBegin, lastEnd));
lastBegin = temp;
}
lastEnd = temp;
}
ranges.add(Range.closed(lastBegin, lastEnd));
return ranges;
}
}
代码示例来源:origin: plutext/docx4j
result.add(attribute);
return result.iterator();
代码示例来源:origin: plutext/docx4j
visiblyUtilized.add(prefix);
result.add(attribute);
} else if (!(XML.equals(NName) && XML_LANG_URI.equals(NNodeValue))
&& ns.addMapping(NName, NNodeValue, attribute)
prefix = XMLNS;
visiblyUtilized.add(prefix);
return result.iterator();
代码示例来源:origin: google/guava
/**
* A sensible definition of {@link #remove} in terms of the {@code iterator()} method of {@link
* #tailSet}. If you override {@link #tailSet}, you may wish to override {@link #remove} to
* forward to this implementation.
*
* @since 7.0
*/
@Override
@Beta
protected boolean standardRemove(@Nullable Object object) {
try {
// any ClassCastExceptions are caught
@SuppressWarnings("unchecked")
SortedSet<Object> self = (SortedSet<Object>) this;
Iterator<Object> iterator = self.tailSet(object).iterator();
if (iterator.hasNext()) {
Object ceiling = iterator.next();
if (unsafeCompare(ceiling, object) == 0) {
iterator.remove();
return true;
}
}
} catch (ClassCastException | NullPointerException e) {
return false;
}
return false;
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new instance of {@code TreeSet} containing the elements of
* the specified SortedSet and using the same Comparator.
*
* @param set
* the SortedSet of elements to add.
*/
public TreeSet(SortedSet<E> set) {
this(set.comparator());
Iterator<E> it = set.iterator();
while (it.hasNext()) {
add(it.next());
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCurrentStateOfEntity1() {
final SortedSetEntity entity1 = getEntityManager().find( SortedSetEntity.class, 1 );
assertEquals( "sortedEntity1", entity1.getData() );
assertEquals( Integer.valueOf( 1 ), entity1.getId() );
final SortedSet<StrTestEntity> sortedSet = entity1.getSortedSet();
assertEquals( StrTestEntityComparator.class, sortedSet.comparator().getClass() );
assertEquals( 4, sortedSet.size() );
final Iterator<StrTestEntity> iterator = sortedSet.iterator();
checkStrTestEntity( iterator.next(), id2, "aaa" );
checkStrTestEntity( iterator.next(), id4, "aac" );
checkStrTestEntity( iterator.next(), id3, "aba" );
checkStrTestEntity( iterator.next(), id1, "abc" );
final SortedMap<StrTestEntity, String> sortedMap = entity1.getSortedMap();
assertEquals( StrTestEntityComparator.class, sortedMap.comparator().getClass() );
assertEquals( 4, sortedMap.size() );
Iterator<Map.Entry<StrTestEntity, String>> mapIterator = sortedMap.entrySet().iterator();
checkStrTestEntity( mapIterator.next().getKey(), id2, "aaa" );
checkStrTestEntity( mapIterator.next().getKey(), id4, "aac" );
checkStrTestEntity( mapIterator.next().getKey(), id3, "aba" );
checkStrTestEntity( mapIterator.next().getKey(), id1, "abc" );
mapIterator = sortedMap.entrySet().iterator();
assertEquals( mapIterator.next().getValue(), "aaa" );
assertEquals( mapIterator.next().getValue(), "aac" );
assertEquals( mapIterator.next().getValue(), "aba" );
assertEquals( mapIterator.next().getValue(), "abc" );
}
代码示例来源:origin: google/guava
@Override
public K firstKey() {
// correctly throws NoSuchElementException when filtered map is empty.
return keySet().iterator().next();
}
代码示例来源:origin: plutext/docx4j
result.add(attribute);
} else if (!(XML.equals(NName) && XML_LANG_URI.equals(NValue))) {
result.add((Attr)n);
if (C14nHelper.namespaceIsRelative(attribute)) {
Object exArgs[] = {element.getTagName(), NName, attribute.getNodeValue()};
return result.iterator();
代码示例来源:origin: loklak/loklak_server
private static SortedSet<File> tailSet(SortedSet<File> set, int count) {
if (count >= set.size()) return set;
TreeSet<File> t = new TreeSet<File>();
Iterator<File> fi = set.iterator();
for (int i = 0; i < set.size() - count; i++) fi.next();
while (fi.hasNext()) t.add(fi.next());
return t;
}
代码示例来源:origin: marytts/marytts
/**
* @param args
* args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties p = System.getProperties();
SortedSet keys = new TreeSet(p.keySet());
for (Iterator it = keys.iterator(); it.hasNext();) {
String key = (String) it.next();
System.out.println(key + " = " + p.getProperty(key));
}
}
代码示例来源:origin: checkstyle/checkstyle
/**
* Tests IO exception, that can occur during reading of properties file.
*/
@Test
public void testIoException() throws Exception {
final DefaultConfiguration checkConfig = createModuleConfig(UniquePropertiesCheck.class);
final UniquePropertiesCheck check = new UniquePropertiesCheck();
check.configure(checkConfig);
final String fileName =
getPath("InputUniquePropertiesCheckNotExisting.properties");
final File file = new File(fileName);
final FileText fileText = new FileText(file, Collections.emptyList());
final SortedSet<LocalizedMessage> messages =
check.process(file, fileText);
assertEquals("Wrong messages count: " + messages.size(),
1, messages.size());
final LocalizedMessage message = messages.iterator().next();
final String retrievedMessage = messages.iterator().next().getKey();
assertEquals("Message key '" + retrievedMessage
+ "' is not valid", "unable.open.cause",
retrievedMessage);
assertEquals("Message '" + message.getMessage()
+ "' is not valid", message.getMessage(),
getCheckMessage(MSG_IO_EXCEPTION_KEY, fileName, getFileNotFoundDetail(file)));
}
代码示例来源:origin: prestodb/presto
@Override
public K firstKey() {
// correctly throws NoSuchElementException when filtered map is empty.
return keySet().iterator().next();
}
代码示例来源:origin: plutext/docx4j
result.add(attribute);
} else if (!(XML.equals(NName) && XML_LANG_URI.equals(NValue))) {
result.add((Attr)n);
if (C14nHelper.namespaceIsRelative(attribute)) {
Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
return result.iterator();
代码示例来源:origin: geoserver/geoserver
protected SortedSet<GeoServerUserGroup> filterGroups(SortedSet<GeoServerUserGroup> groups) {
for (Iterator<GeoServerUserGroup> it = groups.iterator(); it.hasNext(); ) {
if (filterGroup(it.next()) == null) {
it.remove();
}
}
return groups;
}
}
代码示例来源:origin: marytts/marytts
/**
* @param args
* args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties p = System.getProperties();
SortedSet keys = new TreeSet(p.keySet());
for (Iterator it = keys.iterator(); it.hasNext();) {
String key = (String) it.next();
System.out.println(key + " = " + p.getProperty(key));
}
}
代码示例来源:origin: hibernate/hibernate-orm
assertEquals( 0, sortedSet.size() );
assertEquals( 1, sortedSet.size() );
Iterator<StrTestEntity> iterator = sortedSet.iterator();
checkStrTestEntity( iterator.next(), id1, "abc" );
assertEquals( 1, sortedMap.size() );
Iterator<Map.Entry<StrTestEntity, String>> mapIterator = sortedMap.entrySet().iterator();
checkStrTestEntity( mapIterator.next().getKey(), id1, "abc" );
assertEquals( mapIterator.next().getValue(), "abc" );
assertEquals( 2, sortedSet.size() );
iterator = sortedSet.iterator();
checkStrTestEntity( iterator.next(), id2, "aaa" );
checkStrTestEntity( iterator.next(), id1, "abc" );
assertEquals( StrTestEntityComparator.class, sortedSet.comparator().getClass() );
assertEquals( 3, sortedSet.size() );
iterator = sortedSet.iterator();
checkStrTestEntity( iterator.next(), id2, "aaa" );
checkStrTestEntity( iterator.next(), id3, "aba" );
assertEquals( StrTestEntityComparator.class, sortedSet.comparator().getClass() );
assertEquals( 4, sortedSet.size() );
iterator = sortedSet.iterator();
checkStrTestEntity( iterator.next(), id2, "aaa" );
checkStrTestEntity( iterator.next(), id4, "aac" );
代码示例来源:origin: wildfly/wildfly
@Override
public K firstKey() {
// correctly throws NoSuchElementException when filtered map is empty.
return keySet().iterator().next();
}
内容来源于网络,如有侵权,请联系作者删除!