当前位置: 首页>>代码示例>>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;未经允许,请勿转载。