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


Java TreeSet.last方法代码示例

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


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

示例1: findPlatform

import java.util.TreeSet; //导入方法依赖的package包/类
private static File findPlatform() {
    try {
        Class<?> lookup = Class.forName("org.openide.util.Lookup"); // NOI18N
        File util = new File(lookup.getProtectionDomain().getCodeSource().getLocation().toURI());
        Assert.assertTrue("Util exists: " + util, util.exists());

        return util.getParentFile().getParentFile();
    } catch (Exception ex) {
        try {
            File nbjunit = new File(MeasureStartupTimeTestCase.class.getProtectionDomain().getCodeSource().getLocation().toURI());
            File harness = nbjunit.getParentFile().getParentFile();
            Assert.assertEquals("NbJUnit is in harness", "harness", harness.getName());
            TreeSet<File> sorted = new TreeSet<>();
            for (File p : harness.getParentFile().listFiles()) {
                if (p.getName().startsWith("platform")) {
                    sorted.add(p);
                }
            }
            Assert.assertFalse("Platform shall be found in " + harness.getParent(), sorted.isEmpty());
            return sorted.last();
        } catch (Exception ex2) {
            Assert.fail("Cannot find utilities JAR: " + ex + " and: " + ex2);
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:MeasureStartupTimeTestCase.java

示例2: checkRangeInternal

import java.util.TreeSet; //导入方法依赖的package包/类
private int checkRangeInternal ( final long oldestPossibleTimestamp )
{
    final TreeSet<DataItemValueLight> toRemove = new TreeSet<DataItemValueLight> ();
    for ( final DataItemValueLight dataItemValueLight : this.values )
    {
        if ( dataItemValueLight.getTimestamp () < oldestPossibleTimestamp )
        {
            toRemove.add ( dataItemValueLight );
        }
    }
    if ( !toRemove.isEmpty () )
    {
        this.firstValue = toRemove.last ();
        this.values.removeAll ( toRemove );
    }
    this.oldestPossibleTimestamp = oldestPossibleTimestamp;
    return this.values.size ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:DataItemValueRange.java

示例3: addOption

import java.util.TreeSet; //导入方法依赖的package包/类
/**
    * Ajax call, will add one more input line for new resource item instruction.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward addOption(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
TreeSet<AssessmentQuestionOption> optionList = getOptionsFromRequest(request, false);
AssessmentQuestionOption option = new AssessmentQuestionOption();
int maxSeq = 1;
if ((optionList != null) && (optionList.size() > 0)) {
    AssessmentQuestionOption last = optionList.last();
    maxSeq = last.getSequenceId() + 1;
}
option.setSequenceId(maxSeq);
option.setGrade(0);
optionList.add(option);

request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID,
	WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID));
request.setAttribute(AssessmentConstants.ATTR_QUESTION_TYPE,
	WebUtil.readIntParam(request, AssessmentConstants.ATTR_QUESTION_TYPE));
request.setAttribute(AssessmentConstants.ATTR_OPTION_LIST, optionList);
return mapping.findForward(AssessmentConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:AuthoringAction.java

示例4: 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

示例5: newOverallFeedback

import java.util.TreeSet; //导入方法依赖的package包/类
/**
    * Ajax call, will add one more input line for new OverallFeedback.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward newOverallFeedback(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
TreeSet<AssessmentOverallFeedback> overallFeedbackList = getOverallFeedbacksFromRequest(request, false);
AssessmentOverallFeedback overallFeedback = new AssessmentOverallFeedback();
int maxSeq = 1;
if ((overallFeedbackList != null) && (overallFeedbackList.size() > 0)) {
    AssessmentOverallFeedback last = overallFeedbackList.last();
    maxSeq = last.getSequenceId() + 1;
}
overallFeedback.setSequenceId(maxSeq);
overallFeedbackList.add(overallFeedback);

request.setAttribute(AssessmentConstants.ATTR_OVERALL_FEEDBACK_LIST, overallFeedbackList);
return mapping.findForward(AssessmentConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AuthoringAction.java

示例6: findNetbeans

import java.util.TreeSet; //导入方法依赖的package包/类
private static File findNetbeans() {
    try {
        Class<?> lookup = Class.forName("org.openide.util.Lookup"); // NOI18N
        File util = new File(lookup.getProtectionDomain().getCodeSource().getLocation().toURI());
        Assert.assertTrue("Util exists: " + util, util.exists());
        return util.getParentFile().getParentFile().getParentFile();
    } catch (Exception ex) {
        try {
            File nbjunit = new File(NbModuleSuite.class.getProtectionDomain().getCodeSource().getLocation().toURI());
            File harness = nbjunit.getParentFile().getParentFile();
            Assert.assertEquals("NbJUnit is in harness", "harness", harness.getName());
            TreeSet<File> sorted = new TreeSet<>();
            File[] listFiles = harness.getParentFile().listFiles();
            if (listFiles != null) {
                for (File p : listFiles) {
                    if (p.getName().startsWith("platform")) {
                        sorted.add(p);
                    }
                }
            }
            Assert.assertFalse("Platform shall be found in " + harness.getParent(), sorted.isEmpty());
            return sorted.last();
        } catch (Exception ex2) {
            Assert.fail("Cannot find utilities JAR: " + ex + " and: " + ex2);
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NbClustersInfoProvider.java

示例7: 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

示例8: findByIndex

import java.util.TreeSet; //导入方法依赖的package包/类
public static ExamPeriod findByIndex(Long sessionId, ExamType type, Integer idx) {
    if (idx==null || idx<0) return null;
    int x = 0;
    TreeSet periods = findAll(sessionId, type);
    for (Iterator i=periods.iterator();i.hasNext();x++) {
        ExamPeriod period = (ExamPeriod)i.next();
        if (x==idx) return period;
    }
    return (periods.isEmpty()?null:(ExamPeriod)periods.last());
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:11,代码来源:ExamPeriod.java

示例9: getSubjectAreas

import java.util.TreeSet; //导入方法依赖的package包/类
protected Set<SubjectArea> getSubjectAreas(Long selectedSessionId) {
	Set<SubjectArea> subjects = new TreeSet<SubjectArea>();
	Session session = null;
	if (selectedSessionId == null){
		boolean found = false;
		TreeSet<Session> allSessions = Session.getAllSessions();
		List<Session> sessionList = new ArrayList<Session>();
		sessionList.addAll(Session.getAllSessions());
		for (int i = (sessionList.size() - 1); i >= 0; i--){
			session = (Session)sessionList.get(i);
			if (session.getStatusType().isAllowRollForward()){
				found =  true;
			}
		}
		if (!found){
			session = null;
			if (allSessions.size() > 0){
				session = (Session)allSessions.last();
			}
		}
	} else {
		session = Session.getSessionById(selectedSessionId);
	}
	
	if (session != null) subjects = session.getSubjectAreas();
	return(subjects);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:28,代码来源:RollForwardSessionAction.java

示例10: getDepartments

import java.util.TreeSet; //导入方法依赖的package包/类
protected Set<Department> getDepartments(Long selectedSessionId) {
	Set<Department> departments = new TreeSet<Department>();
	Session session = null;
	if (selectedSessionId == null){
		boolean found = false;
		TreeSet<Session> allSessions = Session.getAllSessions();
		List<Session> sessionList = new ArrayList<Session>();
		sessionList.addAll(Session.getAllSessions());
		for (int i = (sessionList.size() - 1); i >= 0; i--){
			session = (Session)sessionList.get(i);
			if (session.getStatusType().isAllowRollForward()){
				found =  true;
			}
		}
		if (!found){
			session = null;
			if (allSessions.size() > 0){
				session = (Session)allSessions.last();
			}
		}
	} else {
		session = Session.getSessionById(selectedSessionId);
	}
	
	if (session != null) departments = session.getDepartments();
	return(departments);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:28,代码来源:RollForwardSessionAction.java

示例11: findBestServers

import java.util.TreeSet; //导入方法依赖的package包/类
private List/* <LoadHolder> */ findBestServers(Map groupServers, Set excludedServers, int count) {
  TreeSet bestEntries = new TreeSet(new Comparator() {
    public int compare(Object o1, Object o2) {
      LoadHolder l1 = (LoadHolder) o1;
      LoadHolder l2 = (LoadHolder) o2;
      int difference = Float.compare(l1.getLoad(), l2.getLoad());
      if (difference != 0) {
        return difference;
      }
      ServerLocation sl1 = l1.getLocation();
      ServerLocation sl2 = l2.getLocation();
      return sl1.compareTo(sl2);
    }
  });

  float lastBestLoad = Float.MAX_VALUE;
  for (Iterator itr = groupServers.entrySet().iterator(); itr.hasNext();) {
    Map.Entry next = (Entry) itr.next();
    ServerLocation location = (ServerLocation) next.getKey();
    if (excludedServers.contains(location)) {
      continue;
    }
    LoadHolder nextLoadReference = (LoadHolder) next.getValue();
    float nextLoad = nextLoadReference.getLoad();

    if (bestEntries.size() < count || count == -1 || nextLoad < lastBestLoad) {
      bestEntries.add(nextLoadReference);
      if (count != -1 && bestEntries.size() > count) {
        bestEntries.remove(bestEntries.last());
      }
      LoadHolder lastBestHolder = (LoadHolder) bestEntries.last();
      lastBestLoad = lastBestHolder.getLoad();
    }
  }

  return new ArrayList(bestEntries);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:38,代码来源:LocatorLoadSnapshot.java

示例12: getTransactionalLock

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void getTransactionalLock(QName lockQName, long timeToLive, long retryWait, int retryCount)
{
    // Check that transaction is present
    final String txnId = AlfrescoTransactionSupport.getTransactionId();
    if (txnId == null)
    {
        throw new IllegalStateException("Locking requires an active transaction");
    }
    // Get the set of currently-held locks
    TreeSet<QName> heldLocks = TransactionalResourceHelper.getTreeSet(KEY_RESOURCE_LOCKS);
    // We don't want the lock registered as being held if something goes wrong
    TreeSet<QName> heldLocksTemp = new TreeSet<QName>(heldLocks);
    boolean added = heldLocksTemp.add(lockQName);
    if (!added)
    {
        // It's a refresh.  Ordering is not important here as we already hold the lock.
        refreshLock(txnId, lockQName, timeToLive);
    }
    else
    {
        QName lastLock = heldLocksTemp.last();
        if (lastLock.equals(lockQName))
        {
            if (logger.isDebugEnabled())
            {
                logger.debug(
                        "Attempting to acquire ordered lock: \n" +
                        "   Lock:     " + lockQName + "\n" +
                        "   TTL:      " + timeToLive + "\n" +
                        "   Txn:      " + txnId);
            }
            // If it was last in the set, then the order is correct and we use the
            // full retry behaviour.
            getLockImpl(txnId, lockQName, timeToLive, retryWait, retryCount);
        }
        else
        {
            if (logger.isDebugEnabled())
            {
                logger.debug(
                        "Attempting to acquire UNORDERED lock: \n" +
                        "   Lock:     " + lockQName + "\n" +
                        "   TTL:      " + timeToLive + "\n" +
                        "   Txn:      " + txnId);
            }
            // The lock request is made out of natural order.
            // Unordered locks do not get any retry behaviour
            getLockImpl(txnId, lockQName, timeToLive, retryWait, 1);
        }
    }
    // It went in, so add it to the transactionally-stored set
    heldLocks.add(lockQName);
    // Done
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:59,代码来源:JobLockServiceImpl.java

示例13: scaleDownDetour

import java.util.TreeSet; //导入方法依赖的package包/类
public static ArrayList<Attribute> scaleDownDetour(Instances previousSet, Instance center){
	ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
	int attNum = center.numAttributes();
	
	int pos = previousSet.attribute(PerformanceAttName).index();
	
	//traverse each dimension
	Enumeration<Instance> enu;
	double minDis;
	for(int i=0;i<attNum;i++){
		if(i==pos)
			continue;
		
		enu = previousSet.enumerateInstances();
		minDis = Double.MAX_VALUE;
		
		while(enu.hasMoreElements()){
			Instance ins = enu.nextElement();
			if(!ins.equals(center))
				minDis = Math.min((double)((int)(Math.abs(ins.value(i)-center.value(i))*100))/100.0, minDis);
		}
		
		//now we set the range
		Properties p1 = new Properties();
		double upper = center.value(i)+minDis, lower=center.value(i)-minDis;
		
		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,项目名称:BestConfig,代码行数:57,代码来源:BestConf.java

示例14: 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

示例15: saveNewItem

import java.util.TreeSet; //导入方法依赖的package包/类
/**
    * Stores uploaded entryId(s).
    */
   public ActionForward saveNewItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {
initKalturaService();

String sessionMapID = WebUtil.readStrParam(request, KalturaConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
KalturaUser user = (KalturaUser) sessionMap.get(AttributeNames.USER);
Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);

KalturaSession kalturaSession = service.getSessionBySessionId(toolSessionId);
Kaltura kaltura = kalturaSession.getKaltura();
TreeSet<KalturaItem> allItems = new TreeSet<KalturaItem>(new KalturaItemComparator());
allItems.addAll(kaltura.getKalturaItems());

// check user can upload item
boolean isAllowUpload = isAllowUpload(sessionMap, allItems);
if (!isAllowUpload) {
    return null;
}

KalturaItem item = new KalturaItem();
item.setCreateDate(new Timestamp(new Date().getTime()));
int maxSeq = 1;
if (allItems != null && allItems.size() > 0) {
    KalturaItem last = allItems.last();
    maxSeq = last.getSequenceId() + 1;
}
item.setSequenceId(maxSeq);

String title = WebUtil.readStrParam(request, KalturaConstants.PARAM_ITEM_TITLE, true);
if (StringUtils.isBlank(title)) {
    String itemLocalized = service.getLocalisedMessage("label.authoring.item", null);
    title = itemLocalized + " " + maxSeq;
}
item.setTitle(title);

int duration = WebUtil.readIntParam(request, KalturaConstants.PARAM_ITEM_DURATION);
item.setDuration(duration);

String entryId = WebUtil.readStrParam(request, KalturaConstants.PARAM_ITEM_ENTRY_ID);
if (StringUtils.isBlank(entryId)) {
    String errorMsg = "Add item failed due to missing entityId (received from Kaltura server).";
    log.error(errorMsg);
    throw new KalturaException(errorMsg);
}
item.setEntryId(entryId);

item.setCreatedBy(user);
item.setCreateByAuthor(false);
item.setHidden(false);
item.setKalturaUid(kaltura.getUid());
service.saveKalturaItem(item);

JSONObject JSONObject = new JSONObject();
JSONObject.put(KalturaConstants.PARAM_ITEM_UID, item.getUid());
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(JSONObject);
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:64,代码来源:LearningAction.java


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