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


Java TreeSet.first方法代码示例

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


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

示例1: getMessage

import java.util.TreeSet; //导入方法依赖的package包/类
public String getMessage(Class_ clazz, boolean hasCourseExam, boolean hasSectionExam, Hashtable<Long,ClassEvent> class2event) {
    TreeSet<ExamAssignmentInfo> exams = getExams(clazz);
    if (!exams.isEmpty()) return "";
    String message = "** NO EXAM **";
    if (hasCourseExam && !hasSectionExam) message = ""; // Has other exam
    if (!hasSectionExam && !clazz.getSchedulingSubpart().getItype().isOrganized()) message = "Not organized instructional type";
    else {
        ClassEvent event = class2event.get(clazz.getUniqueId());
        if (event==null || event.getMeetings().isEmpty()) {
            message = "Class not organized";
        } else if (!isFullTerm(event)) {
            TreeSet meetings = new TreeSet(event.getMeetings());
            Meeting first = (Meeting)meetings.first();
            Meeting last = (Meeting)meetings.last();
            SimpleDateFormat df = new SimpleDateFormat("MM/dd");
            message = "Class not full-term ("+df.format(first.getMeetingDate())+(first.getMeetingDate().equals(last.getMeetingDate())?"":" - "+df.format(last.getMeetingDate()))+")";
        }
    }
    return message;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:21,代码来源:ExamVerificationReport.java

示例2: setFirstChild

import java.util.TreeSet; //导入方法依赖的package包/类
private void setFirstChild(TreeSet<Oplog> oplogSet, boolean force) {
  if (parent.isOffline() && !parent.isOfflineCompacting() && !parent.isOfflineModify())
    return;
  if (!oplogSet.isEmpty()) {
    Oplog first = oplogSet.first();
    DirectoryHolder dh = first.getDirectoryHolder();
    dirCounter = dh.getArrayIndex();
    dirCounter = (++dirCounter) % parent.dirLength;
    // we want the first child to go in the directory after the directory
    // used by the existing oplog with the max id.
    // This fixes bug 41822.
  }
  if (force || maxRecoveredOplogId > 0) {
    setChild(new Oplog(maxRecoveredOplogId + 1, this, getNextDir()));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:PersistentOplogSet.java

示例3: adviseEldestGatewaySender

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * Find out if this sender is the eldest in the DS. Returns true if: 1. No other sender is running
 * 2. At least one sender is running in the system apart from this sender AND this sender's start
 * time is lesser of all (i.e. this sender is oldest)
 * 
 * @return boolean true if this eldest sender; false otherwise
 */
private boolean adviseEldestGatewaySender() {
  Profile[] snapshot = this.profiles;

  // sender with minimum startTime is eldest. Find out the minimum start time
  // of remote senders.
  TreeSet<Long> senderStartTimes = new TreeSet<Long>();
  for (Profile profile : snapshot) {
    GatewaySenderProfile sp = (GatewaySenderProfile) profile;
    if (!sp.isParallel && sp.isRunning) {
      senderStartTimes.add(sp.startTime);
    }
  }

  // if none of the remote senders is running, then this sender should
  // volunteer for primary
  // if there are remote senders running and this sender is not running then
  // it should give up
  // and allow existing running senders to volunteer
  return (senderStartTimes.isEmpty())
      || (this.sender.isRunning() && (this.sender.startTime <= senderStartTimes.first()));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:29,代码来源:GatewaySenderAdvisor.java

示例4: main

import java.util.TreeSet; //导入方法依赖的package包/类
public static void main(String ... ags)throws IOException
{
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(in.readLine());
	StringTokenizer tk = new StringTokenizer(in.readLine());
	TreeSet<Integer> ts = new TreeSet<>();
	while(tk.hasMoreTokens())
		ts.add(Integer.parseInt(tk.nextToken()));
	int count = 0;
	while(ts.size()>0)
	{
		int x = ts.first() + 4;
		count++;
		while(ts.size()>0 && ts.first() <= x)
		{
			ts.pollFirst();
		}
	}
	System.out.println(count);
}
 
开发者ID:hell-sing,项目名称:hacker-rank,代码行数:21,代码来源:Priyanka_and_toys.java

示例5: getInputOutput

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * Tries to find free Output Window tab for the given name.
 *
 * @param name the name of the free tab. Other free tabs are ignored.
 * @return free tab and its current display name or <tt>null</tt>
 */
public static InputOutputData getInputOutput(String name, boolean actions, String optionsPath) {
    InputOutputData result = null;

    TreeSet<InputOutputData> candidates = new TreeSet<InputOutputData>(InputOutputData.DISPLAY_NAME_COMPARATOR);

    synchronized (InputOutputManager.class) {
        for (Iterator<Entry<InputOutput, InputOutputData>> it = AVAILABLE.entrySet().iterator(); it.hasNext();) {
            Entry<InputOutput, InputOutputData> entry = it.next();

            final InputOutput free = entry.getKey();
            final InputOutputData data = entry.getValue();

            if (free.isClosed()) {
                it.remove();
                continue;
            }

            if (isAppropriateName(name, data.displayName)) {
                if ((actions && data.rerunAction != null && data.stopAction != null)
                        || !actions && data.rerunAction == null && data.stopAction == null) {
                    if (optionsPath != null && data.optionsAction != null && data.optionsAction.getOptionsPath().equals(optionsPath)
                            || optionsPath == null && data.optionsAction == null) {
                        // Reuse it.
                        candidates.add(data);
                    }
                } // continue to remove all closed tabs
            }

            LOGGER.log(Level.FINEST, "InputOutputManager pool: {0}", data.getDisplayName());
        }

        if (!candidates.isEmpty()) {
            result = candidates.first();
            AVAILABLE.remove(result.inputOutput);
            ACTIVE_DISPLAY_NAMES.add(result.displayName);
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:InputOutputManager.java

示例6: nextValue

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * Returns either the next value, or the first value of the tree if the
 * given value is the last one of the tree.
 */
private static double nextValue(TreeSet<Double> tree, double value) {
	if(tree.higher(value)==null)
		return tree.first();
	else
		return tree.higher(value);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:11,代码来源:CirculinearCurve2DUtils.java

示例7: judge

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * 歧义识别
 * @param lexemeCell 歧义路径链表头
 * @param fullTextLength 歧义路径文本长度
 * @param option 候选结果路径
 * @return
 */
private LexemePath judge(QuickSortSet.Cell lexemeCell , int fullTextLength){
	//候选路径集合
	TreeSet<LexemePath> pathOptions = new TreeSet<LexemePath>();
	//候选结果路径
	LexemePath option = new LexemePath();
	
	//对crossPath进行一次遍历,同时返回本次遍历中有冲突的Lexeme栈
	Stack<QuickSortSet.Cell> lexemeStack = this.forwardPath(lexemeCell , option);
	
	//当前词元链并非最理想的,加入候选路径集合
	pathOptions.add(option.copy());
	
	//存在歧义词,处理
	QuickSortSet.Cell c = null;
	while(!lexemeStack.isEmpty()){
		c = lexemeStack.pop();
		//回滚词元链
		this.backPath(c.getLexeme() , option);
		//从歧义词位置开始,递归,生成可选方案
		this.forwardPath(c , option);
		pathOptions.add(option.copy());
	}
	
	//返回集合中的最优方案
	return pathOptions.first();

}
 
开发者ID:navis87,项目名称:IKAnalyzer,代码行数:35,代码来源:IKArbitrator.java

示例8: getDefaultLocale

import java.util.TreeSet; //导入方法依赖的package包/类
private String getDefaultLocale()
{
	Map<String, HtmlValueState> localeMap = state.getLocaleMap();
	TreeSet<Locale> editableLocales = new TreeSet<Locale>(localeComparator);

	Locale firstValidLoc = null;
	for( Map.Entry<String, HtmlValueState> entry : localeMap.entrySet() )
	{
		Locale locale = LocaleUtils.parseLocale(entry.getKey());
		if( !Check.isEmpty(entry.getValue().getValue()) && firstValidLoc == null )
		{
			firstValidLoc = locale;
		}
		editableLocales.add(locale);
	}

	Locale currentLocale = CurrentLocale.getLocale();

	if( !editableLocales.contains(currentLocale) )
	{
		Locale closestLocale = LocaleUtils.getClosestLocale(editableLocales, currentLocale);

		if( closestLocale != null )
		{
			currentLocale = closestLocale;

			if( !isEmpty(localeMap.values()) && Check.isEmpty(localeMap.get(closestLocale.toString()).getValue()) )
			{
				currentLocale = firstValidLoc;
			}
		}
		else
		{
			currentLocale = editableLocales.first();
		}
	}

	return currentLocale.toString();
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:MultiEditBoxRenderer.java

示例9: judge

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * 歧义识别
 * @param lexemeCell 歧义路径链表头
 * @param fullTextLength 歧义路径文本长度
 * @return
 */
private LexemePath judge(QuickSortSet.Cell lexemeCell , int fullTextLength){
	//候选路径集合
	TreeSet<LexemePath> pathOptions = new TreeSet<LexemePath>();
	//候选结果路径
	LexemePath option = new LexemePath();
	
	//对crossPath进行一次遍历,同时返回本次遍历中有冲突的Lexeme栈
	Stack<QuickSortSet.Cell> lexemeStack = this.forwardPath(lexemeCell , option);
	
	//当前词元链并非最理想的,加入候选路径集合
	pathOptions.add(option.copy());
	
	//存在歧义词,处理
	QuickSortSet.Cell c = null;
	while(!lexemeStack.isEmpty()){
		c = lexemeStack.pop();
		//回滚词元链
		this.backPath(c.getLexeme() , option);
		//从歧义词位置开始,递归,生成可选方案
		this.forwardPath(c , option);
		pathOptions.add(option.copy());
	}
	
	//返回集合中的最优方案
	return pathOptions.first();

}
 
开发者ID:judasn,项目名称:Elasticsearch-Tutorial-zh-CN,代码行数:34,代码来源:IKArbitrator.java

示例10: getBound

import java.util.TreeSet; //导入方法依赖的package包/类
public double getBound(Hashtable conflictsToResolve) {
	double value = iSolver.currentSolution().getModel().getTotalValue(iAssignment);
	for (Enumeration e=conflictsToResolve.keys();e.hasMoreElements();) {
		Lecture lect = (Lecture)e.nextElement();
		TreeSet<PlacementValue> values = values(lect);
		if (!values.isEmpty()) {
			PlacementValue val = values.first();
			value += val.getValue();
		}
	}
	return value;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:Suggestions.java

示例11: getLockPath

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected String getLockPath(String createdZNode, List<String> children) throws IOException {
  TreeSet<String> sortedChildren =
      new TreeSet<String>(ZNodeComparator.COMPARATOR);
  sortedChildren.addAll(children);
  String pathToWatch = sortedChildren.lower(createdZNode);
  if (pathToWatch != null) {
    String nodeHoldingLock = sortedChildren.first();
    String znode = ZKUtil.joinZNode(parentLockNode, nodeHoldingLock);
    handleLockMetadata(znode);
  }
  return pathToWatch;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:ZKInterProcessWriteLock.java

示例12: 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:nsg-ethz,项目名称:iTAP-controller,代码行数:31,代码来源:OFSwitchManager.java

示例13: getShortestPath

import java.util.TreeSet; //导入方法依赖的package包/类
public static java.util.ArrayList<Vector> getShortestPath(Vector start, Vector end, Dijkstra.Description desc)
{
	TreeSet<Vector> closedSet = new TreeSet<Vector>();
	TreeSet<FVWrapper> openSet = new TreeSet<FVWrapper>();
	openSet.add(new FVWrapper(start, heuristic(start, end)));
	
	TreeMap<Vector, Vector> cameFrom = new TreeMap<Vector, Vector>();
	TreeMap<Vector, Double> gScore = new TreeMap<Vector, Double>();
	gScore.put(start, 0.0);
	
	TreeMap<Vector, Double> fScore = new TreeMap<Vector, Double>();
	fScore.put(start, heuristic(start, end));
	
	while(!openSet.isEmpty())
	{
		FVWrapper current = openSet.first();
		openSet.remove(current);
		
		if(current.v.equals(end))
			return getReturn(cameFrom, current.v);
		
		closedSet.add(current.v);
		
		java.util.List<Vector> neighbor = desc.getNeighbor(current.v);
		
		for(int i = 0 ; i < neighbor.size() ; i++)
		{
			Vector nei = neighbor.get(i); 
			if(!closedSet.contains(nei))
			{
				FVWrapper neiOpen = new FVWrapper(nei, null); 
				
				double tenative = gScore.get(current.v) + current.v.skew(nei);
				
				Double g = gScore.get(nei);
				g = g == null? Triangle.LARGE_VALUE : g;
				if(tenative < g)
				{
					cameFrom.put(nei, current.v);
					gScore.put(nei, tenative);
					double f = g + heuristic(nei, end);
					fScore.put(nei, f);
					
					neiOpen.fScore = f;
					
					
				}
				
				openSet.add(neiOpen);
			}
		}
	}
	
	return null;
}
 
开发者ID:ben-j-c,项目名称:TopDownGame,代码行数:56,代码来源:AStar.java

示例14: getInputOutput

import java.util.TreeSet; //导入方法依赖的package包/类
private static CachedInputOutput getInputOutput(String name, List<Action> actions) {
    CachedInputOutput result = null;

    TreeSet<CachedInputOutput> candidates = new TreeSet<>(CachedInputOutput.DISPLAY_NAME_COMPARATOR);

    synchronized (InputOutputCache.class) {
        for (Iterator<Entry<InputOutput, CachedInputOutput>> it = AVAILABLE.entrySet().iterator(); it.hasNext();) {
            Entry<InputOutput, CachedInputOutput> entry = it.next();

            final InputOutput free = entry.getKey();
            final CachedInputOutput data = entry.getValue();

            if (free.isClosed()) {
                it.remove();
                continue;
            }

            if (isAppropriateName(name, data.getDisplayName())) {
                List<Action> candidateActions = data.getActions();
                if (candidateActions.isEmpty() && (actions == null || actions.isEmpty())) {
                    candidates.add(data);
                } else if (actions != null && candidateActions.size() == actions.size()) {
                    boolean differs = false;
                    for (int i = 0; i < candidateActions.size(); i++) {
                        if (candidateActions.get(i).getClass() != actions.get(i).getClass()) {
                            differs = true;
                            break;
                        }
                    }
                    if (!differs) {
                        candidates.add(data);
                    }
                } // continue to remove all closed tabs
            }

            LOGGER.log(Level.FINEST, "Pooled: {0}", data.getDisplayName());
        }

        if (!candidates.isEmpty()) {
            result = candidates.first();
            AVAILABLE.remove(result.getInputOutput());
            ACTIVE_DISPLAY_NAMES.add(result.getDisplayName());
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:InputOutputCache.java

示例15: scaleDownNeighbordists

import java.util.TreeSet; //导入方法依赖的package包/类
private static ArrayList<Attribute> scaleDownNeighbordists(Instances previousSet, Instance center){
	ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
	int attNum = center.numAttributes();
	
	int pos = -1;
	if(previousSet.attribute(PerformanceAttName)!=null)
		pos = previousSet.attribute(PerformanceAttName).index();
	
	//traverse each dimension
	Enumeration<Instance> enu;
	double[] minDists = new double[2];
	double val;
	for(int i=0;i<attNum;i++){
		if(i==pos)
			continue;
		
		enu = previousSet.enumerateInstances();
		minDists[0] = 1-Double.MAX_VALUE;
		minDists[1] = Double.MAX_VALUE;
		
		while(enu.hasMoreElements()){
			Instance ins = enu.nextElement();
			if(!ins.equals(center)){
				val = ins.value(i)-center.value(i);
				if(val<0)
					minDists[0] = Math.max((double)((int)((ins.value(i)-center.value(i))*1000))/1000.0, minDists[0]);
				else
					minDists[1] = Math.min((double)((int)((ins.value(i)-center.value(i))*1000))/1000.0, minDists[1]);
			}
		}
		
		//now we set the range
		Properties p1 = new Properties();
		double upper = center.value(i)+minDists[1], lower=center.value(i)+minDists[0];
		
		TreeSet<Double> detourSet = new TreeSet<Double>();
		detourSet.add(upper);
		detourSet.add(lower);
		detourSet.add(previousSet.attribute(i).getUpperNumericBound());
		detourSet.add(previousSet.attribute(i).getLowerNumericBound());
		switch(detourSet.size()){
		case 1:
			upper=lower=detourSet.first();
			break;
		case 2:
			upper = detourSet.last();
			lower = detourSet.first();
			break;
		case 3:
			upper=lower=detourSet.higher(detourSet.first());
			break;
		default://case 4:
			upper=detourSet.lower(detourSet.last());
			lower=detourSet.higher(detourSet.first());
			break;
		}
		
		p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
		ProtectedProperties prop1 = new ProtectedProperties(p1);
		
		localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
	}
	
	return localAtts;
}
 
开发者ID:zhuyuqing,项目名称:bestconf,代码行数:66,代码来源:ConfigSampler.java


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