當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeSet.size方法代碼示例

本文整理匯總了Java中java.util.TreeSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeSet.size方法的具體用法?Java TreeSet.size怎麽用?Java TreeSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.TreeSet的用法示例。


在下文中一共展示了TreeSet.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SpanWeight

import java.util.TreeSet; //導入方法依賴的package包/類
public SpanWeight(SpanQuery query, IndexSearcher searcher)
  throws IOException {
  this.similarity = searcher.getSimilarity();
  this.query = query;
  
  termContexts = new HashMap<>();
  TreeSet<Term> terms = new TreeSet<>();
  query.extractTerms(terms);
  final IndexReaderContext context = searcher.getTopReaderContext();
  final TermStatistics termStats[] = new TermStatistics[terms.size()];
  int i = 0;
  for (Term term : terms) {
    TermContext state = TermContext.build(context, term);
    termStats[i] = searcher.termStatistics(term, state);
    termContexts.put(term, state);
    i++;
  }
  final String field = query.getField();
  if (field != null) {
    stats = similarity.computeWeight(query.getBoost(), 
                                     searcher.collectionStatistics(query.getField()), 
                                     termStats);
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:SpanWeight.java

示例2: getClassCoverage

import java.util.TreeSet; //導入方法依賴的package包/類
/**
 * With respect to a subset of stations (SUBNET),
 * a) a class of customers is fully covered if the stations that the class visits are a subset of SUBNET,
 * b) a class of customers is noncovered if the intersection between the stations that the class visits and SUBNET is empty,
 * c) a class of customers is partially covered if only some of the stations that the class visits are in SUBNET.
 * @param cls The class of customers.
 * @param subnet The subnetwork of stations.
 * @return An enum describing whether the class is fully, non or partially covered with respect to the subnetwork.
 */
public Covered getClassCoverage(int cls, TreeSet<Integer> subnet) {
	TreeSet<Integer> stationsVisitedByClass = stationsVisitedByClass(cls);
	int count = 0;
	for (int k : stationsVisitedByClass) {
		if (!subnet.contains(k)) {
			count++;
		}
	}

	if (count == stationsVisitedByClass.size()) {
		return Covered.NON;
	} else if (count > 0) {
		return Covered.PARTIALLY;
	}
	return Covered.FULLY;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:26,代碼來源:ClassCoverageUtils.java

示例3: createUserDictSettings

import java.util.TreeSet; //導入方法依賴的package包/類
/**
 * Creates the entries that allow the user to go into the user dictionary for each locale.
 * @param userDictGroup The group to put the settings in.
 */
protected void createUserDictSettings(final PreferenceGroup userDictGroup) {
    final Activity activity = getActivity();
    userDictGroup.removeAll();
    final TreeSet<String> localeSet =
            UserDictionaryList.getUserDictionaryLocalesSet(activity);

    if (localeSet.size() > 1) {
        // Have an "All languages" entry in the languages list if there are two or more active
        // languages
        localeSet.add("");
    }

    if (localeSet.isEmpty()) {
        userDictGroup.addPreference(createUserDictionaryPreference(null));
    } else {
        for (String locale : localeSet) {
            userDictGroup.addPreference(createUserDictionaryPreference(locale));
        }
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:25,代碼來源:UserDictionaryList.java

示例4: contract

import java.util.TreeSet; //導入方法依賴的package包/類
/**
 * Contracts a population vector to the necessary size depending on partially covered classes in smallPcs.
 * @param largePopVec The population vector containing populations for each class in largePcs.
 * @param largePcs The set of partially covered classes corresponding to the largePopVec.
 * @param smallPcs The set of partially covered classes we want to find populations for.
 * @return The population vector containing populations for each class in smallPcs.
 */
public PopulationVector contract(
	PopulationVector largePopVec,
	TreeSet<Integer> largePcs,
	TreeSet<Integer> smallPcs) {
		
	PopulationVector contracted = new PopulationVector(0, smallPcs.size());
	int smallIdx = 0;
	int largeIdx = 0;
	for (int k : largePcs) {
		if (smallPcs.contains(k)) {
			contracted.set(smallIdx, largePopVec.get(largeIdx));
			smallIdx++;
		}
		largeIdx++;
	}
	
	return contracted;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:26,代碼來源:ClassCoverageUtils.java

示例5: main

import java.util.TreeSet; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    TreeSet<Character> letters = new TreeSet<>();
    try (BufferedReader fileReader = new BufferedReader(new FileReader(args[0]))) {
        while (fileReader.ready()) {
            String s = fileReader.readLine().toLowerCase().replaceAll("[^\\p{Alpha}]",""); //\s\p{Punct}
            for (int i = 0; i < s.length(); i++)
                letters.add(s.charAt(i));
        }
    }

    Iterator<Character> iterator = letters.iterator();
    int n = letters.size() < 5 ? letters.size() : 5;

    for (int i = 0; i < n; i++) {
        System.out.print((iterator.next()));
    }
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:18,代碼來源:Solution.java

示例6: overwriteUserDictionaryPreference

import java.util.TreeSet; //導入方法依賴的package包/類
private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) {
    final Activity activity = getActivity();
    final TreeSet<String> localeList = UserDictionaryList.getUserDictionaryLocalesSet(activity);
    if (null == localeList) {
        // The locale list is null if and only if the user dictionary service is
        // not present or disabled. In this case we need to remove the preference.
        getPreferenceScreen().removePreference(userDictionaryPreference);
    } else if (localeList.size() <= 1) {
        userDictionaryPreference.setFragment(UserDictionarySettings.class.getName());
        // If the size of localeList is 0, we don't set the locale parameter in the
        // extras. This will be interpreted by the UserDictionarySettings class as
        // meaning "the current locale".
        // Note that with the current code for UserDictionaryList#getUserDictionaryLocalesSet()
        // the locale list always has at least one element, since it always includes the current
        // locale explicitly. @see UserDictionaryList.getUserDictionaryLocalesSet().
        if (localeList.size() == 1) {
            final String locale = (String)localeList.toArray()[0];
            userDictionaryPreference.getExtras().putString("locale", locale);
        }
    } else {
        userDictionaryPreference.setFragment(UserDictionaryList.class.getName());
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:24,代碼來源:CorrectionSettingsFragment.java

示例7: quantize

import java.util.TreeSet; //導入方法依賴的package包/類
/**
 * Main method for computing the quantization intervals.
 *
 * Invoked in the constructor after all input variables are initialized.  Walks
 * over the inputs and builds the min. penalty forest of intervals with exactly nLevel
 * root nodes.  Finds this min. penalty forest via greedy search, so is not guarenteed
 * to find the optimal combination.
 *
 * TODO: develop a smarter algorithm
 *
 * @return the forest of intervals with size == nLevels
 */
private TreeSet<QualInterval> quantize() {
    // create intervals for each qual individually
    final TreeSet<QualInterval> intervals = new TreeSet<QualInterval>();
    for ( int qStart = 0; qStart < getNQualsInHistogram(); qStart++ ) {
        final long nObs = nObservationsPerQual.get(qStart);
        final double errorRate = QualityUtils.qualToErrorProb((byte)qStart);
        final double nErrors = nObs * errorRate;
        final QualInterval qi = new QualInterval(qStart, qStart, nObs, (int)Math.floor(nErrors), 0, (byte)qStart);
        intervals.add(qi);
    }

    // greedy algorithm:
    // while ( n intervals >= nLevels ):
    //   find intervals to merge with least penalty
    //   merge it
    while ( intervals.size() > nLevels ) {
        mergeLowestPenaltyIntervals(intervals);
    }

    return intervals;
}
 
開發者ID:PAA-NCIC,項目名稱:SparkSeq,代碼行數:34,代碼來源:QualQuantizer.java

示例8: writeTreeSet

import java.util.TreeSet; //導入方法依賴的package包/類
/**
 * Writes a <code>TreeSet</code> to a <code>DataOutput</code>. Note that even though
 * <code>set</code> may be an instance of a subclass of <code>TreeSet</code>,
 * <code>readTreeSet</code> will always return an instance of <code>TreeSet</code>, <B>not</B> an
 * instance of the subclass. To preserve the class type of <code>set</code>,
 * {@link #writeObject(Object, DataOutput)} should be used for data serialization.
 * <p>
 * If the set has a comparator then it must also be serializable.
 *
 * @throws IOException A problem occurs while writing to <code>out</code>
 *
 * @see #readTreeSet
 */
public static void writeTreeSet(TreeSet<?> set, DataOutput out) throws IOException {
  InternalDataSerializer.checkOut(out);

  int size;

  if (set == null) {
    size = -1;
  } else {
    size = set.size();
  }
  InternalDataSerializer.writeArrayLength(size, out);
  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "Writing TreeSet with {} elements: {}", size, set);
  }
  if (size >= 0) {
    writeObject(set.comparator(), out);
    for (Object e : set) {
      writeObject(e, out);
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:35,代碼來源:DataSerializer.java

示例9: newUnit

import java.util.TreeSet; //導入方法依賴的package包/類
/**
    * Ajax call, will add one more input line for new Unit.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward newUnit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
TreeSet<AssessmentUnit> unitList = getUnitsFromRequest(request, false);
AssessmentUnit unit = new AssessmentUnit();
int maxSeq = 1;
if ((unitList != null) && (unitList.size() > 0)) {
    AssessmentUnit last = unitList.last();
    maxSeq = last.getSequenceId() + 1;
}
unit.setSequenceId(maxSeq);
unitList.add(unit);

request.setAttribute(AssessmentConstants.ATTR_UNIT_LIST, unitList);
return mapping.findForward(AssessmentConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:AuthoringAction.java

示例10: calcNumRequiredConnections

import java.util.TreeSet; //導入方法依賴的package包/類
private int calcNumRequiredConnections() {
	if(!this.logicalOFMessageCategories.isEmpty()){
		// We use tree set here to maintain ordering
		TreeSet<OFAuxId> auxConnections = new TreeSet<OFAuxId>();

		for(LogicalOFMessageCategory category : this.logicalOFMessageCategories){
			auxConnections.add(category.getAuxId());
		}

		OFAuxId first = auxConnections.first();
		OFAuxId last = auxConnections.last();

		// Check for contiguous set (1....size())
		if(first.equals(OFAuxId.MAIN)) {
			if(last.getValue() != auxConnections.size() - 1){
				throw new IllegalStateException("Logical OF message categories must maintain contiguous OF Aux Ids! i.e. (0,1,2,3,4,5)");
			}
			return auxConnections.size() - 1;
		} else if(first.equals(OFAuxId.of(1))) {
			if(last.getValue() != auxConnections.size()){
				throw new IllegalStateException("Logical OF message categories must maintain contiguous OF Aux Ids! i.e. (1,2,3,4,5)");
			}
			return auxConnections.size();
		} else {
			throw new IllegalStateException("Logical OF message categories must start at 0 (MAIN) or 1");
		}
	} else {
		return 0;
	}
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:31,代碼來源:OFSwitchManager.java

示例11: toArray

import java.util.TreeSet; //導入方法依賴的package包/類
private static long[] toArray(TreeSet<Long> set) {
    int i = 0;
    long[] result = new long[set.size()];

    for (long e : set) {
        result[i++] = e;
    }

    return result;
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:11,代碼來源:TimestampDialogFragment.java

示例12: populateEntryEventMap

import java.util.TreeSet; //導入方法依賴的package包/類
private void populateEntryEventMap(DistributedMember target,
    ArrayList<ArrayList<DistTxThinEntryState>> entryEventList, TreeSet<String> sortedRegionName) {
  if (this.txEntryEventMap == null) {
    this.txEntryEventMap = new HashMap<String, ArrayList<DistTxThinEntryState>>();
  }

  DistTXCoordinatorInterface distTxIface = target2realDeals.get(target);
  if (distTxIface.getPrimaryTransactionalOperations() != null
      && distTxIface.getPrimaryTransactionalOperations().size() > 0) {
    sortedRegionName.clear();
    distTxIface.gatherAffectedRegionsName(sortedRegionName, true, false);

    if (sortedRegionName.size() != entryEventList.size()) {
      throw new UnsupportedOperationInTransactionException(
          LocalizedStrings.DISTTX_TX_EXPECTED.toLocalizedString(
              "size of " + sortedRegionName.size() + " {" + sortedRegionName + "}"
                  + " for target=" + target,
              entryEventList.size() + " {" + entryEventList + "}"));
    }

    int index = 0;
    // Get region as per sorted order of region path
    for (String rName : sortedRegionName) {
      txEntryEventMap.put(rName, entryEventList.get(index++));
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:28,代碼來源:DistTXStateProxyImplOnCoordinator.java

示例13: execute

import java.util.TreeSet; //導入方法依賴的package包/類
/** 
 * Method execute
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward execute(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response) throws Exception{
	RoomGroupEditForm roomGroupEditForm = (RoomGroupEditForm) form;
	
	MessageResources rsc = getResources(request);
	String doit = roomGroupEditForm.getDoit();
	
	if (doit != null) {
		//add new
		if(doit.equals(rsc.getMessage("button.addNew"))) {
			ActionMessages errors = new ActionMessages();
			errors = roomGroupEditForm.validate(mapping, request);
	        if(errors.size()==0) {
	        	save(mapping, roomGroupEditForm, request, response);
				return mapping.findForward("showRoomGroupList");
	        } else {
	        	saveErrors(request, errors);
	        }
		}
		
		//return to room list
		if(doit.equals(rsc.getMessage("button.returnToRoomGroupList"))) {
			return mapping.findForward("showRoomGroupList");
		}
	}
	
	//get depts owned by user
	LookupTables.setupDepartments(request, sessionContext, false);
	
       //set default department
	TreeSet<Department> departments = Department.getUserDepartments(sessionContext.getUser());
       if (departments.size() == 1) {
       	roomGroupEditForm.setDeptCode(departments.first().getDeptCode());
       } else {
       	String deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom);
       	if (deptCode != null && !deptCode.isEmpty() && !deptCode.equals("All") && !deptCode.matches("Exam[0-9]*"))
       		roomGroupEditForm.setDeptCode(deptCode);
	}
	
	if (roomGroupEditForm.getDeptCode() == null || roomGroupEditForm.getDeptCode().isEmpty() || roomGroupEditForm.getDeptCode().matches("Exam[0-9]*") ||
		!sessionContext.hasPermission(roomGroupEditForm.getDeptCode(), "Department", Right.DepartmentRoomGroupAdd)) {
		sessionContext.checkPermission(Right.GlobalRoomGroupAdd);
		roomGroupEditForm.setGlobal(true);
	} else {
		sessionContext.checkPermission(roomGroupEditForm.getDeptCode(), "Department", Right.DepartmentRoomGroupAdd);
		roomGroupEditForm.setGlobal(false);
	}
	
	roomGroupEditForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId());
	
	return mapping.findForward("showAdd");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:64,代碼來源:RoomGroupAddAction.java

示例14: initLeafNode

import java.util.TreeSet; //導入方法依賴的package包/類
/**
 * Initialises the specified leaf node, using the formulas in Hoyme's paper.
 * @param node The leaf node.
 */
public void initLeafNode(Node node) {
	// Only need to initialise leaf node if it is the only station in the network
	// or it has a parent node that has one leaf child and one non-leaf child.
	// Case when parent has two leaf children is handled by sequential MVA at parent node.
	Node parent = node.parent();
	if (parent != null && parent.childrenAreLeaves()) return;
	
	int station = node.stations.iterator().next();
	TreeSet<Integer> cs = node.getAllCoveredClasses();
	
	PopulationVector pcvec = new PopulationVector(0, cs.size());
	PopulationVector pcmax = ccu.contract(qnm.N, ccu.all, cs); 
	
	Printer.out.println("\nInit leaf node: station = " + station + " pcs = " 
			+ node.pcs + " cs = " + node.getAllCoveredClasses());
	
	int nsum, nr;
	double demand, mul, val;
	
	while (pcvec != null) {
		PopulationVector n = pcvec;
		nsum = n.sum();
		
		Printer.out.println("--- N = " + n.toString() + " ---");
		
		MVAResults res = new MVAResults(1, cs.size());
		int ri = 0;
		for (int r : cs) {
			nr = n.get(ri);
			demand = qnm.getDemand(station, r);
			mul = (double)nsum/(double)nr;
			val = nr == 0 ? 0 : demand * mul;
			res.X[ri] = val == 0 ? 0 : 1/val;
			res.Q[0][ri] = nr;
			ri++;
		}
		
		node.mvaRes.put(n, res);
		pcvec = ccu.nextPermutationUpwards(pcvec, pcmax);
	}
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:46,代碼來源:TMVACore.java

示例15: isUnivariate

import java.util.TreeSet; //導入方法依賴的package包/類
public boolean isUnivariate(){
TreeSet<NumericVariable> vars = new TreeSet<NumericVariable>();
collectNumericVariables(vars);
return vars.size() == 1;
   }
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:6,代碼來源:Polynomial.java


注:本文中的java.util.TreeSet.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。