本文整理汇总了Java中java.util.LinkedHashSet.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedHashSet.iterator方法的具体用法?Java LinkedHashSet.iterator怎么用?Java LinkedHashSet.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedHashSet
的用法示例。
在下文中一共展示了LinkedHashSet.iterator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMap
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Get back a Map of String*String from its String representation.
* Unescape backslashed separator characters.
* @param string String to convert to a Map
* @return a Map
* @see #toString(java.util.Map)
*/
public static Map<String, String> toMap(String string) {
Map<String, String> map = new HashMap<String, String>();
if (string == null
|| string.length() < 3) {
return map;
}
Set<String> firstList = toSet(string, ", ");
for (String element : firstList) {
LinkedHashSet<String> secondList = toSet("[" + element + "]", "=");
if (secondList.size() == 2) {
Iterator<String> iterator = secondList.iterator();
map.put(iterator.next(), iterator.next());
} else {
Err.prln("Ignoring element: [" + element + "]");
Err.prln("Expecting: [key=value]");
}
}
return map;
}
示例2: getResources
import java.util.LinkedHashSet; //导入方法依赖的package包/类
@Override
public Enumeration<URL> getResources(String name) throws IOException {
final LinkedHashSet<URL> resourceUrls = new LinkedHashSet<URL>();
for ( ClassLoader classLoader : individualClassLoaders ) {
final Enumeration<URL> urls = classLoader.getResources( name );
while ( urls.hasMoreElements() ) {
resourceUrls.add( urls.nextElement() );
}
}
return new Enumeration<URL>() {
final Iterator<URL> resourceUrlIterator = resourceUrls.iterator();
@Override
public boolean hasMoreElements() {
return resourceUrlIterator.hasNext();
}
@Override
public URL nextElement() {
return resourceUrlIterator.next();
}
};
}
示例3: main
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public static void main(String[] args) {
//create object of LinkedHashSet
LinkedHashSet lhashSet = new LinkedHashSet();
//add elements to LinkedHashSet object
lhashSet.add(new Integer("1"));
lhashSet.add(new Integer("2"));
lhashSet.add(new Integer("3"));
//get the Iterator
Iterator itr = lhashSet.iterator();
System.out.println("LinkedHashSet contains : ");
while (itr.hasNext()) System.out.println(itr.next());
}
示例4: truncate
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Truncates the given list to a list containing the first MAX_NUMBER_ENTRIES entries of that list.
* <p>
* Does not modify the original list.
*
* @param fileList the original list
* @return the truncated list
*/
@SuppressWarnings("PMD.LooseCoupling") // LinkedHashSet must be used because its contents must be ordered
private static LinkedHashSet<File> truncate(final LinkedHashSet<File> fileList) {
final LinkedHashSet<File> truncatedSet = new LinkedHashSet<>();
final Iterator<File> fileIterator = fileList.iterator();
while (fileIterator.hasNext() && truncatedSet.size() < MAX_NUMBER_ENTRIES) {
truncatedSet.add(fileIterator.next());
}
return truncatedSet;
}
示例5: getIndexInLinkedHashSet
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* 获取linkedHashSet中元素的索引位置
*
* @param linkedHashSet
* @param string
* @return
*/
public static int getIndexInLinkedHashSet(LinkedHashSet<String> linkedHashSet, String string) {
int index = -1;
Iterator<String> linkedSetStringIt = linkedHashSet.iterator();
while (linkedSetStringIt.hasNext()) {
index++;
String temp = linkedSetStringIt.next();
if (temp.equals(string)) {
return index;
}
}
return -1;
}
示例6: convertAndAddImport
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private static void convertAndAddImport(LinkedHashSet<Import> allImports, List<Node> thisImport) {
boolean isStatic = false;
String importItem = null;
String prefix = "";
String suffix = "";
for (Node n : thisImport) {
if (n instanceof Comment) {
if (importItem == null) {
prefix += n.toString();
} else {
suffix += n.toString();
}
}
if (n instanceof ImportDeclaration) {
ImportDeclaration i = (ImportDeclaration) n;
isStatic = i.isStatic();
importItem = i.getName().asString() + (i.isAsterisk() ? ".*" : "");
}
}
suffix = suffix.trim();
if (!suffix.isEmpty()) {
suffix = " " + suffix;
}
Import imp = new Import(isStatic, importItem, prefix.trim(), suffix);
Iterator<Import> iter = allImports.iterator();
// this de-duplication can probably be made more efficient by doing it all at the end
while (iter.hasNext()) {
Import candidate = iter.next(); // potential duplicate
if (candidate.isDuplicatedBy(imp)) {
iter.remove();
imp = candidate.combineWith(imp);
}
}
allImports.add(imp);
}
示例7: createDocComment
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
*
*/
private String[] createDocComment(boolean hasReturnType,
LinkedHashSet<TypeDescriptor> throwsTypes,
String[] methodDescription, String returnTypeDescription) {
ArrayList<String> lines = new ArrayList<>();
if (methodDescription != null) {
for (int i=0;i<methodDescription.length;i++) {
lines.add(methodDescription[i]);
}
}
boolean hasThrowTypes = !throwsTypes.isEmpty();
if ((methodDescription != null) && (methodDescription.length > 0) &&
(hasReturnType || hasThrowTypes)) {
lines.add("");
}
if (hasReturnType) {
lines.add("@return "+returnTypeDescription);
}
if (hasThrowTypes) {
Iterator<TypeDescriptor> iterator = throwsTypes.iterator();
while (iterator.hasNext()) {
TypeDescriptor curType = iterator.next();
String typeName = curType.getSimpleName();
String typeDescription = getThrowableDescription(curType);
lines.add("@throws "+typeName+" "+typeDescription);
}
}
return lines.toArray(SystemToolkit.EMPTY_STRING_ARRAY);
}
示例8: interfaceApiSupertypeWalker
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* This methods takes an API-Element and pulls the projectComparisons along the suptertype chain.
*
* Does nothing if apiElement is null.
*
* @param filter
* applied to each encountered projectComparison
* @param actionProvider
* function to apply on filtered ProjectComparinsonEntries.
* @param apiElement
* concrete API element to start from.
*/
public <T extends TClassifier> void interfaceApiSupertypeWalker(Predicate<? super ProjectComparisonEntry> filter,
Function<T, Consumer<? super ProjectComparisonEntry>> actionProvider,
ProjectComparisonAdapter projectComparisonAdapter, /* ProjectComparisonEntry compareEntry, */
T apiElement, Class<T> castGuard) {
if (apiElement == null) {
// no apiElemnt means no one can directly call the concrete implementation
// from projects
return;
}
LinkedHashSet<T> toBeProcessedSuperInterfaces = new LinkedHashSet<>();
LinkedHashSet<T> processedSuperInterfaces = new LinkedHashSet<>();
// Yes it is correct ~Not correct~, since we need VirtualMethods for the direct missing parts:: //
toBeProcessedSuperInterfaces.add(apiElement);
// includeAdditionsSuperInterfaces(toBeProcessedSuperInterfaces, processedSuperInterfaces, apiInterface);
while (!toBeProcessedSuperInterfaces.isEmpty()) {
Iterator<T> iter = toBeProcessedSuperInterfaces.iterator();
T pivot = iter.next();
iter.remove();
// do not process built-in types
if (TypeUtils.isBuiltIn(pivot)) {
continue;
}
// collect to be processed:
includeAdditionsSuperInterfaces2(toBeProcessedSuperInterfaces, processedSuperInterfaces, pivot, castGuard);
// go over methods.
// Is the superInterface from the same Project ? If not it cannot be an API problem of this
// implementation.
TModule superModule = pivot.getContainingModule();
if (superModule != null) {
ProjectComparisonEntry useCompareEntry = projectComparisonAdapter.getEntryFor(superModule);
if (useCompareEntry == null) {
if (logger.isDebugEnabled()) {
logger.debug("No comparison found for pivot = " + pivot.getName());
}
} else {
// Is there an API entry at all ? --> If not it was just a normal implementation of some library ?
ProjectComparisonEntry superInterfaceCompareEntry = useCompareEntry.getChildForElementAPI(pivot);
if (superInterfaceCompareEntry != null) {
// Is there a difference between this API and the implementations ?
if (superInterfaceCompareEntry.hasChildren()) {
// get the ones which are missing implementations; others are real errors and will not be
// touched!
superInterfaceCompareEntry.allChildren()
.filter(filter)
.forEach(actionProvider.apply(pivot));
}
} // end if superInterfaceCompareEntry != null
}
} // end if null-check for module...
else {
if (logger.isDebugEnabled()) {
logger.debug("-#- could not get module for super-classifier: " + pivot.getName() + " of type "
+ pivot.getTypeAsString() + " providedByRuntime=" + pivot.isProvidedByRuntime());
}
}
}
}
示例9: getEventThrowers
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public Iterator<IEventThrower<?>> getEventThrowers(Class<?> interfaceClass){
synchronized (EVENT_THROWERS) {
LinkedHashSet<IEventThrower<?>> eventThrower = EVENT_THROWERS.get(interfaceClass);
return eventThrower.iterator();
}
}