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


Java Collection.size方法代码示例

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


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

示例1: remove

import java.util.Collection; //导入方法依赖的package包/类
@Override public int remove(@Nullable Object element, int occurrences) {
  checkNonnegative(occurrences, "occurrences");
  if (occurrences == 0) {
    return count(element);
  }

  Collection<V> values = Maps.safeGet(multimap.asMap(), element);

  if (values == null) {
    return 0;
  }

  int oldCount = values.size();
  if (occurrences >= oldCount) {
    values.clear();
  } else {
    Iterator<V> iterator = values.iterator();
    for (int i = 0; i < occurrences; i++) {
      iterator.next();
      iterator.remove();
    }
  }
  return oldCount;
}
 
开发者ID:s-store,项目名称:s-store,代码行数:25,代码来源:Multimaps.java

示例2: setClosingTransactionIDs

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Set the Closing Transaction IDs
 * <p>
 * The IDs of the Transactions that have closed portions of this Trade.
 * <p>
 * @param closingTransactionIDs the Closing Transaction IDs
 * @return {@link Trade Trade}
 * @see TransactionID
 */
public Trade setClosingTransactionIDs(Collection<?> closingTransactionIDs) {
    ArrayList<TransactionID> newClosingTransactionIDs = new ArrayList<TransactionID>(closingTransactionIDs.size());
    closingTransactionIDs.forEach((item) -> {
        if (item instanceof TransactionID)
        {
            newClosingTransactionIDs.add((TransactionID) item);
        }
        else if (item instanceof String)
        {
            newClosingTransactionIDs.add(new TransactionID((String) item));
        }
        else
        {
            throw new IllegalArgumentException(
                item.getClass().getName() + " cannot be converted to a TransactionID"
            );
        }
    });
    this.closingTransactionIDs = newClosingTransactionIDs;
    return this;
}
 
开发者ID:oanda,项目名称:v20-java,代码行数:31,代码来源:Trade.java

示例3: isEqualCollection

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Returns {@code true} iff the given {@link Collection}s contain
 * exactly the same elements with exactly the same cardinalities.
 * <p>
 * That is, iff the cardinality of <i>e</i> in <i>a</i> is
 * equal to the cardinality of <i>e</i> in <i>b</i>,
 * for each element <i>e</i> in <i>a</i> or <i>b</i>.
 *
 * @param a  the first collection, must not be null
 * @param b  the second collection, must not be null
 * @return <code>true</code> iff the collections contain the same elements with the same cardinalities.
 */
public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b) {
    if(a.size() != b.size()) {
        return false;
    }
    final CardinalityHelper<Object> helper = new CardinalityHelper<Object>(a, b);
    if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
        return false;
    }
    for( final Object obj : helper.cardinalityA.keySet()) {
        if(helper.freqA(obj) != helper.freqB(obj)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:CollectionUtils.java

示例4: toArray

import java.util.Collection; //导入方法依赖的package包/类
/**
 * 
 */
private Expression[] toArray(Collection<? extends Expression> expressionList) {
    
    // NOTE: This method exists in order to ensure that the array is
    // actually immutable. toArray of the collection could return a
    // non-constant array.
    
    if (expressionList != null) {
        int size = expressionList.size();
        Expression[] result = new Expression[size];
        
        if (size > 0) {
            Iterator<? extends Expression> iterator  = expressionList.iterator();
            int i = 0;
            
            while (iterator.hasNext()) {
                result[i++] = iterator.next();
            }
        }
        
        return result;
    }
    
    return null;
}
 
开发者ID:annoflex,项目名称:annoflex,代码行数:28,代码来源:ExpressionList.java

示例5: doTask

import java.util.Collection; //导入方法依赖的package包/类
@TaskAction
public void doTask() throws IOException, SigningException {

    File mainDexFile = getMainDexFile();
    Collection<File> awbApkFiles = getAwbApkFiles();
    int size = awbApkFiles.size();
    if (mainDexFile != null) {
        size++;
    }

    if (size > 1) {
        throw new IllegalStateException("Multi bundle is not supported yet.");
    }
    AwoInstaller.installAwoSo(getBuilder(), mainDexFile, awbApkFiles, getPackageName(), getLogger());
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:16,代码来源:AwoInstallTask.java

示例6: handle

import java.util.Collection; //导入方法依赖的package包/类
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<List<String>>();
    Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
    int registeredCount = 0;
    int subscribedCount = 0;
    if (registries != null && registries.size() > 0) {
        for (Registry registry : registries) {
            String server = registry.getUrl().getAddress();
            List<String> row = new ArrayList<String>();
            row.add(NetUtils.getHostName(server) + "/" + server);
            if (registry.isAvailable()) {
                row.add("<font color=\"green\">Connected</font>");
            } else {
                row.add("<font color=\"red\">Disconnected</font>");
            }
            int registeredSize = 0;
            int subscribedSize = 0;
            if (registry instanceof AbstractRegistry) {
                registeredSize = ((AbstractRegistry) registry).getRegistered().size();
                registeredCount += registeredSize;
                subscribedSize = ((AbstractRegistry) registry).getSubscribed().size();
                subscribedCount += subscribedSize;
            }
            row.add("<a href=\"registered.html?registry=" + server + "\">Registered(" + registeredSize + ")</a>");
            row.add("<a href=\"subscribed.html?registry=" + server + "\">Subscribed(" + subscribedSize + ")</a>");
            rows.add(row);
        }
    }
    return new Page("Registries", "Registries (" + rows.size() + ")",
            new String[] { "Registry Address:", "Status", "Registered(" + registeredCount + ")", "Subscribed(" + subscribedCount + ")" }, rows);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:32,代码来源:RegistriesPageHandler.java

示例7: removeAll

import java.util.Collection; //导入方法依赖的package包/类
/**
 * @see java.util.List#removeAll(Collection)
 */
public boolean removeAll(Collection coll) {
	if ( coll.size()>0 ) {
		write();
		return list.removeAll(coll);
	}
	else {
		return false;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:List.java

示例8: removeAll

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Removes all of the elements in <tt>collection</tt> from the set.
 * 
 * @param collection a <code>Collection</code> value
 * @return true if the set was modified by the remove all operation.
 */
public boolean removeAll(Collection collection) {
  boolean changed = false;
  int size = collection.size();

  Iterator it = collection.iterator();
  while (size-- > 0) {
    if (remove(it.next())) {
      changed = true;
    }
  }
  return changed;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:HashIndexSet.java

示例9: fromSymbols

import java.util.Collection; //导入方法依赖的package包/类
/**
 * generate a list of inputColumn where each inputColumn points to some symbol that is part of sourceList
 */
public static List<InputColumn> fromSymbols(Collection<? extends Symbol> symbols, List<? extends Symbol> sourceList) {
    List<InputColumn> inputColumns = new ArrayList<>(symbols.size());
    for (Symbol symbol : symbols) {
        inputColumns.add(new InputColumn(sourceList.indexOf(symbol), symbol.valueType()));
    }
    return inputColumns;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:InputColumn.java

示例10: PdfLegacyExamReport

import java.util.Collection; //导入方法依赖的package包/类
public PdfLegacyExamReport(int mode, OutputStream out, String title, Session session, ExamType examType, Collection<SubjectArea> subjectAreas, Collection<ExamAssignmentInfo> exams) throws DocumentException, IOException {
    super(mode, out, title,
    		ApplicationProperty.ExaminationPdfReportTitle.value(examType == null ? "all" : examType.getReference(), examType == null ? "EXAMINATIONS" : examType.getLabel().toUpperCase() + " EXAMINATIONS"),
            title + " -- " + session.getLabel(), session.getLabel());
    if (subjectAreas!=null && subjectAreas.size() == 1) setFooter(subjectAreas.iterator().next().getSubjectAreaAbbreviation());
    iExams = exams;
    iSession = session;
    iExamType = examType;
    iSubjectAreas = subjectAreas;
    iDispRooms = "true".equals(System.getProperty("room","true"));
    iDispNote = "true".equals(System.getProperty("note","false"));
    iCompact = "true".equals(System.getProperty("compact", "false"));
    iNoRoom = System.getProperty("noroom", ApplicationProperty.ExaminationsNoRoomText.value());
    iDirect = "true".equals(System.getProperty("direct","true"));
    iM2d = "true".equals(System.getProperty("m2d",(examType == null || examType.getType() == ExamType.sExamTypeFinal?"true":"false")));
    iBtb = "true".equals(System.getProperty("btb","false"));
    iLimit = Integer.parseInt(System.getProperty("limit", "-1"));
    iItype = "true".equals(System.getProperty("itype", ApplicationProperty.ExaminationReportsShowInstructionalType.value()));
    iTotals = "true".equals(System.getProperty("totals","true"));
    iUseClassSuffix = "true".equals(System.getProperty("suffix", ApplicationProperty.ExaminationReportsClassSufix.value()));
    iExternal = ApplicationProperty.ExaminationReportsExternalId.isTrue();
    iDispLimits = "true".equals(System.getProperty("verlimit","true"));
    iClassSchedule = "true".equals(System.getProperty("cschedule", ApplicationProperty.ExaminationPdfReportsIncludeClassSchedule.value()));
    iDispFullTermDates = "true".equals(System.getProperty("fullterm","false"));
    iRoomDisplayNames = "true".equals(System.getProperty("roomDispNames", "true"));
    iFullTermCheckDatePattern = ApplicationProperty.ExaminationPdfReportsFullTermCheckDatePattern.isTrue();
    iMeetingTimeUseEvents = ApplicationProperty.ExaminationPdfReportsUseEventsForMeetingTimes.isTrue();
    if (System.getProperty("since")!=null) {
        try {
            iSince = new SimpleDateFormat(System.getProperty("sinceFormat","MM/dd/yy")).parse(System.getProperty("since"));
        } catch (Exception e) {
            sLog.error("Unable to parse date "+System.getProperty("since")+", reason: "+e.getMessage());
        }
    }
    setRoomCode(System.getProperty("roomcode", ApplicationProperty.ExaminationRoomCode.value()));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:37,代码来源:PdfLegacyExamReport.java

示例11: getEventsForDate

import java.util.Collection; //导入方法依赖的package包/类
public static Collection getEventsForDate(CalendarDate date) {
	Vector v = new Vector();
	Day d = getDay(date);
	if (d != null) {
		Elements els = d.getElement().getChildElements("event");
		for (int i = 0; i < els.size(); i++)
			v.add(new EventImpl(els.get(i)));
	}
	Collection r = getRepeatableEventsForDate(date);
	if (r.size() > 0)
		v.addAll(r);
	//EventsVectorSorter.sort(v);
	Collections.sort(v);
	return v;
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:16,代码来源:EventsManager.java

示例12: addAll

import java.util.Collection; //导入方法依赖的package包/类
public boolean addAll(int index, Collection c) {
	if ( c.size()>0 ) {
		//write();
		//return values.addAll(index, c);
		Iterator iter = c.iterator();
		while ( iter.hasNext() ) add( index++, iter.next() );
		return true;
	}
	else {
		return false;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:IdentifierBag.java

示例13: JSONArray

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Construct a JSONArray from a Collection.
 *
 * @param collection
 *            A Collection.
 */
public JSONArray(Collection<?> collection) {
    if (collection == null) {
        this.myArrayList = new ArrayList<Object>();
    } else {
        this.myArrayList = new ArrayList<Object>(collection.size());
    	for (Object o: collection){
    		this.myArrayList.add(JSONObject.wrap(o));
    	}
    }
}
 
开发者ID:Trumeet,项目名称:FlarumSDK,代码行数:17,代码来源:JSONArray.java

示例14: getSelectionValueIds

import java.util.Collection; //导入方法依赖的package包/类
private Set<Long> getSelectionValueIds(boolean preset) {
	Collection<InputFieldSelectionSetValueOutVO> selectionValues = getSelectionValues(preset);
	HashSet<Long> result = new HashSet<Long>(selectionValues.size());
	Iterator<InputFieldSelectionSetValueOutVO> it = selectionValues.iterator();
	while (it.hasNext()) {
		result.add(it.next().getId());
	}
	return result;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:InputFieldPDFBlock.java

示例15: concat

import java.util.Collection; //导入方法依赖的package包/类
public static <T> List<T> concat(Collection<? extends T> coll1, Collection<? extends T> coll2) {
	final List<T> result = new ArrayList<>(coll1.size() + coll2.size());
	result.addAll(coll1);
	result.addAll(coll2);
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:7,代码来源:GraphUtils.java


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