当前位置: 首页>>代码示例>>Java>>正文


Java Collection.iterator方法代码示例

本文整理汇总了Java中java.util.Collection.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.iterator方法的具体用法?Java Collection.iterator怎么用?Java Collection.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collection的用法示例。


在下文中一共展示了Collection.iterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEarliestStartDateFromSubTasks

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Looks through the entire sub task tree and corrects any inconsistencies in start dates
 * 
 * @param t
 * @return
 */
public CalendarDate getEarliestStartDateFromSubTasks(Task t) {
    CalendarDate d = t.getStartDate();
    if (hasSubTasks(t.getID())) {
     Collection subTasks = getAllSubTasks(t.getID());
     for (Iterator iter = subTasks.iterator(); iter.hasNext();) {
     	Task e = (Task) iter.next();
     	CalendarDate dd = getEarliestStartDateFromSubTasks(e);
     	if(dd.before(d)) {
     	    d = dd;
     	}
     }
     t.setStartDate(d);
     return d;
    }
    else {
        return t.getStartDate();
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:25,代码来源:TaskListImpl.java

示例2: modelChanged

import java.util.Collection; //导入方法依赖的package包/类
@Override
public void modelChanged(ModelEvent event) {
    if (event instanceof ModelEvent.NodeChanged && (event.getSource() instanceof NodeModel || event.getSource() instanceof NodeModelFilter)) {
        // CompoundNodeModel.modelChanged() takes this.
        return ;
    }
    if (event instanceof ModelEvent.TableValueChanged &&
            (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) {
        // CompoundTableModel.modelChanged() takes this.
        return ;
    }
    ModelEvent newEvent = translateEvent(event, this);
    Collection<ModelListener> listeners;
    synchronized (modelListeners) {
        listeners = new ArrayList<ModelListener>(modelListeners);
    }
    for (Iterator<ModelListener> it = listeners.iterator(); it.hasNext(); ) {
        it.next().modelChanged(newEvent);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Models.java

示例3: JSONArray

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Construct a JSONArray from a collection of beans.
 * The collection should have Java Beans.
 */

public JSONArray(Collection<?> collection, boolean includeSuperClass) {
    this.myArrayList = new ArrayList<Object>();
    if(collection != null) {
        for (Iterator<?> iter = collection.iterator(); iter.hasNext();) {
            this.myArrayList.add(new JSONObject(iter.next(),includeSuperClass));    
        }
    }
}
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:14,代码来源:JSONArray.java

示例4: findAndRemoveNonOptionsSpec

import java.util.Collection; //导入方法依赖的package包/类
private OptionDescriptor findAndRemoveNonOptionsSpec( Collection<? extends OptionDescriptor> options ) {
    for ( Iterator<? extends OptionDescriptor> it = options.iterator(); it.hasNext(); ) {
        OptionDescriptor next = it.next();
        if ( next.representsNonOptions() ) {
            it.remove();
            return next;
        }
    }

    throw new AssertionError( "no non-options argument spec" );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:BuiltinHelpFormatter.java

示例5: JSONArray

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Construct a JSONArray from a Collection.
 *
 * @param collection
 *            A Collection.
 */
public JSONArray(Collection collection) {
    this.myArrayList = new ArrayList();
    if (collection != null) {
        Iterator iter = collection.iterator();
        while (iter.hasNext()) {
            this.myArrayList.add(JSONObject.wrap(iter.next()));
        }
    }
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:16,代码来源:JSONArray.java

示例6: performMerge

import java.util.Collection; //导入方法依赖的package包/类
/** Merges the existing File into the new code generated file returning the contents as a String
 * @param newTemplate the new code generated file.
 * @param existingFile the existing file.
 * @throws IOException if any IO error occurs.
 * @throws SourceDecomposerException if the file is malformed or if it cannot be decomposed.
 * @return the merged contents.
 */
public static String performMerge(BufferedReader newTemplate, BufferedReader existingFile)
throws IOException, SourceDecomposerException {
    StringBuffer buf = new StringBuffer();
    SourceDecomposer sdNew = new SourceDecomposer(newTemplate);
    SourceDecomposer sdExisting = new SourceDecomposer(existingFile);
    Collection elements = sdNew.getCollection();
    if (elements != null) {
        for (Iterator itr = elements.iterator(); itr.hasNext();) {
            Object obj = itr.next();
            if (obj instanceof SourceDecomposer.PlainText) {
                buf.append(((SourceDecomposer.PlainText) obj).getContents());
            } else if (obj instanceof SourceDecomposer.GuardedBlock) {
                buf.append(((SourceDecomposer.GuardedBlock) obj).getContents());
            } else if (obj instanceof SourceDecomposer.GuardedBorder) {
                SourceDecomposer.GuardedBorder newGB = (SourceDecomposer.GuardedBorder) obj;

                // check if the existing file has this piece of code
                SourceDecomposer.GuardedBorder existingGB = sdExisting.getGuardedBorder( newGB.getKey() );

                if (existingGB != null)
                    buf.append(existingGB.getContents());
                else
                    buf.append(newGB.getContents());
            } else {
                // do nothing
            }

        }
    }
    return buf.toString();
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:39,代码来源:SourceMerge.java

示例7: removeGroups

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Remove exclusive groups from a collection of objects
 * 
 * @param objects
 *            the objects to process
 * @param groupIds
 *            the groups to remove
 */
public static void removeGroups ( final Collection<? extends EObject> objects, final Set<String> groupIds )
{
    if ( groupIds == null || groupIds.isEmpty () )
    {
        return;
    }

    for ( final Iterator<? extends EObject> i = objects.iterator (); i.hasNext (); )
    {
        final EObject obj = i.next ();

        final EAnnotation annotation = findAnnotation ( obj );
        if ( annotation == null )
        {
            continue;
        }

        final String groupId = annotation.getDetails ().get ( VALUE_GROUP_ID );
        if ( groupId == null )
        {
            continue;
        }

        if ( groupIds.contains ( groupId ) )
        {
            i.remove ();
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:38,代码来源:ExclusiveGroups.java

示例8: getAllMatchedKeywords

import java.util.Collection; //导入方法依赖的package包/类
private ArrayList<String> getAllMatchedKeywords(ArrayList<String> keywords, Collection<String> stWords) {
    ArrayList<String> allMatched = new ArrayList<String>();
    Iterator<String> e = stWords.iterator();
           while (e.hasNext()) {
	allMatched.addAll(getMatchedKeywords(keywords, e.next(), allMatched));
           }
    return allMatched;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:OptionsPanel.java

示例9: addAllItems

import java.util.Collection; //导入方法依赖的package包/类
public boolean addAllItems(Collection<? extends CompletionItem> items) {
    boolean cont = true;
    for (Iterator<? extends CompletionItem> it = items.iterator(); it.hasNext();) {
        cont = addItem(it.next());
    }
    return cont;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:CompletionResultSetImpl.java

示例10: attributeNames2String

import java.util.Collection; //导入方法依赖的package包/类
static String attributeNames2String(Collection<String> attributes) {
    StringBuilder sb = new StringBuilder();
    Iterator<String> i = attributes.iterator();
    while (i.hasNext()) {
        String aName = i.next();
        sb.append(aName);
        if (i.hasNext()) {
            sb.append(", "); //NOI18N
        }
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Utils.java

示例11: removeAll

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Removes from this list all of its elements that are contained in the specified collection.
 */
@Override
public boolean removeAll(Collection<?> c) {
	// set modified checking if collection is empty
	boolean modified = !c.isEmpty();
	Iterator<?> e = c.iterator();
	// scans all elements
	while (e.hasNext()) {
		// removes and checks if modified
		modified = modified && remove(e.next());
	}
	return modified;
}
 
开发者ID:pepstock-org,项目名称:Charba,代码行数:16,代码来源:JsStringArrayList.java

示例12: populateComboBox

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Populates a combobox with an array of strings and selects the default
 *
 * @param combobox combobox to be populated
 * @param items    array of strings to be added to the combobox
 * @param selected the default selected item
 */
private void populateComboBox(JComboBox combobox, Collection<String> items, String selected) {
    String item;
    Iterator<String> i = items.iterator();
    int index = 0;
    while (i.hasNext()) {
        item = (String) i.next();
        combobox.addItem(item);
        if (item.equals(selected)) {
            combobox.setSelectedIndex(index);
        }
        index++;
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:21,代码来源:AlignWindow.java

示例13: getParticiaptionCourseIds

import java.util.Collection; //导入方法依赖的package包/类
private static Set<Long> getParticiaptionCourseIds(Staff staff) {
	Collection<CourseParticipationStatusEntry> participations = staff.getParticipations();
	HashSet<Long> courseIds = new HashSet<Long>(participations.size());
	Iterator<CourseParticipationStatusEntry> it = participations.iterator();
	while (it.hasNext()) {
		CourseParticipationStatusEntry participation = it.next();
		if (participation.getStatus().isPass()) {
			courseIds.add(participation.getCourse().getId());
		}
	}
	return courseIds;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:CourseParticipationStatusEntryExpirationAdapter.java

示例14: setIds

import java.util.Collection; //导入方法依赖的package包/类
public void setIds(Collection<Long> ids) {
	clear();
	if (ids != null && ids.size() > 0) {
		Iterator<Long> it = ids.iterator();
		while (it.hasNext()) {
			addId(it.next());
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:MultiPickerModelBase.java

示例15: getDefaultColoring

import java.util.Collection; //导入方法依赖的package包/类
private AttributeSet getDefaultColoring() {
    Collection/*<AttributeSet>*/ defaults = colorModel.getCategories(currentProfile, ColorModel.ALL_LANGUAGES);
    
    for(Iterator i = defaults.iterator(); i.hasNext(); ) {
        AttributeSet as = (AttributeSet) i.next();
        String name = (String) as.getAttribute(StyleConstants.NameAttribute);
        if (name != null && "default".equals(name)) { //NOI18N
            return as;
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:HighlightingPanel.java


注:本文中的java.util.Collection.iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。