本文整理了Java中java.util.HashSet.iterator()
方法的一些代码示例,展示了HashSet.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashSet.iterator()
方法的具体详情如下:
包路径:java.util.HashSet
类名称:HashSet
方法名:iterator
[英]Returns an Iterator on the elements of this HashSet.
[中]返回此哈希集元素的迭代器。
代码示例来源:origin: Tencent/tinker
public static boolean checkFileInPattern(HashSet<Pattern> patterns, String key) {
if (!patterns.isEmpty()) {
for (Iterator<Pattern> it = patterns.iterator(); it.hasNext();) {
Pattern p = it.next();
if (p.matcher(key).matches()) {
return true;
}
}
}
return false;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Returns an Iterator for the users in the queue waiting to be routed to
* an agent (QueueUser instances).
*
* @return an Iterator for the users waiting in the queue.
*/
public Iterator<QueueUser> getUsers() {
if (users == null) {
return new HashSet<QueueUser>().iterator();
}
return Collections.unmodifiableSet(users).iterator();
}
代码示例来源:origin: loklak/loklak_server
@Override
public String getQuery() {
String query = this.queries.iterator().next();
this.queries.remove(query);
return query;
}
代码示例来源:origin: apache/activemq
public boolean isInOneOf(Set<?> allowedPrincipals) {
Iterator<?> allowedIter = allowedPrincipals.iterator();
HashSet<?> userPrincipals = new HashSet<Object>(getPrincipals());
while (allowedIter.hasNext()) {
Iterator<?> userIter = userPrincipals.iterator();
Object allowedPrincipal = allowedIter.next();
while (userIter.hasNext()) {
if (allowedPrincipal.equals(userIter.next()))
return true;
}
}
return false;
}
代码示例来源:origin: OpenNMS/opennms
public java.util.Iterator getPorts() {
if (ports == null) {
ports = new java.util.HashSet();
ports.add(new javax.xml.namespace.QName("http://opennms.org/integration/otrs/ticketservice", "TicketServicePort"));
}
return ports.iterator();
}
代码示例来源:origin: wildfly/wildfly
Expression(Node content) {
this.content = content;
HashSet<String> strings = new HashSet<>();
content.catalog(strings);
referencedStrings = strings.isEmpty() ? Collections.emptySet() : strings.size() == 1 ? Collections.singleton(strings.iterator().next()) : Collections.unmodifiableSet(strings);
}
代码示例来源:origin: hamcrest/JavaHamcrest
@Override
public Iterator<String> getPrefixes(String namespaceURI) {
HashSet<String> prefixes = new HashSet<String>();
String prefix = getPrefix(namespaceURI);
if (prefix != null) {
prefixes.add(prefix);
}
return prefixes.iterator();
}
};
代码示例来源:origin: Sable/soot
private List<AllocNode> getMayAliasList(PointsToSetInternal pts) {
List<AllocNode> list = new ArrayList<AllocNode>();
final HashSet<AllocNode> ret = new HashSet<AllocNode>();
pts.forall(new P2SetVisitor() {
public void visit(Node n) {
ret.add((AllocNode) n);
}
});
Iterator<AllocNode> it = ret.iterator();
while (it.hasNext()) {
list.add(it.next());
}
return list;
}
代码示例来源:origin: Tencent/tinker
public static boolean checkFileInPattern(HashSet<Pattern> patterns, String key) {
if (!patterns.isEmpty()) {
for (Iterator<Pattern> it = patterns.iterator(); it.hasNext();) {
Pattern p = it.next();
if (p.matcher(key).matches()) {
return true;
}
}
}
return false;
}
代码示例来源:origin: OpenNMS/opennms
public java.util.Iterator getPorts() {
if (ports == null) {
ports = new java.util.HashSet();
ports.add(new javax.xml.namespace.QName("urn:HPD_IncidentInterface_Create_WS", "HPD_IncidentInterface_Create_WSPortTypeSoap"));
}
return ports.iterator();
}
代码示例来源:origin: apache/storm
private static InputStream getConfigFileInputStream(String configFilePath)
throws IOException {
if (null == configFilePath) {
throw new IOException(
"Could not find config file, name not specified");
}
HashSet<URL> resources = new HashSet<URL>(findResources(configFilePath));
if (resources.isEmpty()) {
File configFile = new File(configFilePath);
if (configFile.exists()) {
return new FileInputStream(configFile);
}
} else if (resources.size() > 1) {
throw new IOException(
"Found multiple " + configFilePath
+ " resources. You're probably bundling the Storm jars with your topology jar. "
+ resources);
} else {
LOG.debug("Using " + configFilePath + " from resources");
URL resource = resources.iterator().next();
return resource.openStream();
}
return null;
}
代码示例来源:origin: Sable/soot
private Iterator<AllocNode> makePtsIterator(PointsToSetInternal pts) {
final HashSet<AllocNode> ret = new HashSet<AllocNode>();
pts.forall(new P2SetVisitor() {
public void visit(Node n) {
ret.add((AllocNode) n);
}
});
// testPtsIterator(ret.iterator());
return ret.iterator();
}
代码示例来源:origin: prometheus/client_java
private Iterator<Collector> includedCollectorIterator(Set<String> includedNames) {
if (includedNames.isEmpty()) {
return collectors().iterator();
} else {
HashSet<Collector> collectors = new HashSet<Collector>();
synchronized (namesToCollectors) {
for (Map.Entry<String, Collector> entry : namesToCollectors.entrySet()) {
if (includedNames.contains(entry.getKey())) {
collectors.add(entry.getValue());
}
}
}
return collectors.iterator();
}
}
代码示例来源:origin: com.h2database/h2
@Override
public HashSet<Column> getReferencedColumns(Table table) {
HashSet<Column> columns = new HashSet<>();
expr.isEverything(ExpressionVisitor.getColumnsVisitor(columns));
for (Iterator<Column> it = columns.iterator(); it.hasNext();) {
if (it.next().getTable() != table) {
it.remove();
}
}
return columns;
}
代码示例来源:origin: hankcs/HanLP
@Override
public Set<String> keySet()
{
HashSet<String> stringSet = mdag.getAllStrings();
LinkedHashSet<String> keySet = new LinkedHashSet<String>();
Iterator<String> iterator = stringSet.iterator();
while (iterator.hasNext())
{
String key = iterator.next();
keySet.add(key.substring(0, key.length() - 3));
}
return keySet;
}
代码示例来源:origin: OpenNMS/opennms
public java.util.Iterator getPorts() {
if (ports == null) {
ports = new java.util.HashSet();
ports.add(new javax.xml.namespace.QName("HPD_IncidentInterface_WS", "HPD_IncidentInterface_WSPortTypeSoap"));
}
return ports.iterator();
}
代码示例来源:origin: alibaba/jstorm
public static InputStream getConfigFileInputStream(String configFilePath, boolean canMultiple) throws IOException {
if (null == configFilePath) {
throw new IOException("Could not find config file, name not specified");
}
HashSet<URL> resources = new HashSet<>(findResources(configFilePath));
if (resources.isEmpty()) {
File configFile = new File(configFilePath);
if (configFile.exists()) {
return new FileInputStream(configFile);
}
} else if (resources.size() > 1 && !canMultiple) {
throw new IOException("Found multiple " + configFilePath + " resources. " +
"You're probably bundling storm jars with your topology jar. " + resources);
} else {
LOG.debug("Using " + configFilePath + " from resources");
URL resource = resources.iterator().next();
return resource.openStream();
}
return null;
}
代码示例来源:origin: killme2008/Metamorphosis
@Override
public Iterator<BytesKey> keyIterator() {
lock.lock();
try {
return new LRUIndexMapItreator(new HashSet<BytesKey>(map.keySet()).iterator(), handler.getDiskMap()
.iterator());
}
finally {
lock.unlock();
}
}
代码示例来源:origin: lealone/Lealone
@Override
public HashSet<Column> getReferencedColumns(Table table) {
HashSet<Column> columns = new HashSet<>();
expr.getColumns(columns);
for (Iterator<Column> it = columns.iterator(); it.hasNext();) {
if (it.next().getTable() != table) {
it.remove();
}
}
return columns;
}
代码示例来源:origin: FudanNLP/fnlp
private void set2List() {
Iterator<String> it = allC.iterator();
int n = 0;
while (it.hasNext()) {
String s = it.next();
word.add(s);
cmap.put(s, n++);
}
}
内容来源于网络,如有侵权,请联系作者删除!