當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。