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


Java SortedSet.clear方法代码示例

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


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

示例1: removeAnswer

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Ajax call, remove the given answer.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeAnswer(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

SortedSet<ScratchieAnswer> answerList = getAnswersFromRequest(request, false);

int answerIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1);
if (answerIndex != -1) {
    List<ScratchieAnswer> rList = new ArrayList<ScratchieAnswer>(answerList);
    rList.remove(answerIndex);
    answerList.clear();
    answerList.addAll(rList);
}

request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList);
request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID,
	WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID));
return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AuthoringAction.java

示例2: testHeadSetContents

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * headSet returns set with keys in requested range
 */
public void testHeadSetContents() {
    TreeSet set = set5();
    SortedSet sm = set.headSet(four);
    assertTrue(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(four, set.first());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TreeSetTest.java

示例3: handleAttributesSubtree

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Returns the Attr[]s to be output for the given element.
 * <br>
 * The code of this method is a copy of {@link #handleAttributes(Element,
 * NameSpaceSymbTable)},
 * whereas it takes into account that subtree-c14n is -- well -- subtree-based.
 * So if the element in question isRoot of c14n, it's parent is not in the
 * node set, as well as all other ancestors.
 *
 * @param element
 * @param ns
 * @return the Attr[]s to be output
 * @throws CanonicalizationException
 */
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
    throws CanonicalizationException {
    if (!element.hasAttributes()) {
        return null;
    }

    // result will contain all the attrs declared directly on that element
    final SortedSet<Attr> result = this.result;
    result.clear();

    if (element.hasAttributes()) {
        NamedNodeMap attrs = element.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr attribute = (Attr) attrs.item(i);
            result.add(attribute);
        }
    }

    return result.iterator();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:CanonicalizerPhysical.java

示例4: testDescendingHeadSetContents

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * headSet returns set with keys in requested range
 */
public void testDescendingHeadSetContents() {
    NavigableSet set = dset5();
    SortedSet sm = set.headSet(m4);
    assertTrue(sm.contains(m1));
    assertTrue(sm.contains(m2));
    assertTrue(sm.contains(m3));
    assertFalse(sm.contains(m4));
    assertFalse(sm.contains(m5));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(m4, set.first());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TreeSubSetTest.java

示例5: removeItem

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Remove resource item from HttpSession list and update page display. As
    * authoring rule, all persist only happen when user submit whole page. So
    * this remove is just impact HttpSession values.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ResourceConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(ResourceConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<ResourceItem> resourceList = getResourceItemList(sessionMap);
    List<ResourceItem> rList = new ArrayList<ResourceItem>(resourceList);
    ResourceItem item = rList.remove(itemIdx);
    resourceList.clear();
    resourceList.addAll(rList);
    // add to delList
    List delList = getDeletedResourceItemList(sessionMap);
    delList.add(item);
}

request.setAttribute(ResourceConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ResourceConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AuthoringAction.java

示例6: testHeadSetContents

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * headSet returns set with keys in requested range
 */
public void testHeadSetContents() {
    NavigableSet set = set5();
    SortedSet sm = set.headSet(four);
    assertTrue(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(four, set.first());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ConcurrentSkipListSubSetTest.java

示例7: removeItem

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Remove survey item from HttpSession list and update page display. As authoring rule, all persist only happen when
    * user submit whole page. So this remove is just impact HttpSession values.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, SurveyConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(SurveyConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<SurveyQuestion> surveyList = getSurveyItemList(sessionMap);
    List<SurveyQuestion> rList = new ArrayList<SurveyQuestion>(surveyList);
    SurveyQuestion item = rList.remove(itemIdx);
    surveyList.clear();
    surveyList.addAll(rList);
    // add to delList
    List delList = getDeletedSurveyItemList(sessionMap);
    delList.add(item);

    SortedSet<SurveyCondition> list = getSurveyConditionSet(sessionMap);
    Iterator<SurveyCondition> conditionIter = list.iterator();

    while (conditionIter.hasNext()) {
	SurveyCondition condition = conditionIter.next();
	Set<SurveyQuestion> questions = condition.getQuestions();
	if (questions.contains(item)) {
	    questions.remove(item);
	}
    }
}

request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(SurveyConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:AuthoringAction.java

示例8: removeCondition

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Remove condition from HttpSession list and update page display. As authoring rule, all persist only happen when
    * user submit whole page. So this remove is just impact HttpSession values.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, SurveyConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);

int orderId = NumberUtils.stringToInt(request.getParameter(SurveyConstants.PARAM_ORDER_ID), -1);
if (orderId != -1) {
    SortedSet<SurveyCondition> conditionSet = getSurveyConditionSet(sessionMap);
    List<SurveyCondition> conditionList = new ArrayList<SurveyCondition>(conditionSet);
    SurveyCondition condition = conditionList.remove(orderId);
    for (SurveyCondition otherCondition : conditionSet) {
	if (otherCondition.getOrderId() > orderId) {
	    otherCondition.setOrderId(otherCondition.getOrderId() - 1);
	}
    }
    conditionSet.clear();
    conditionSet.addAll(conditionList);
    // add to delList
    List deletedList = getDeletedSurveyConditionList(sessionMap);
    deletedList.add(condition);
}

request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(SurveyConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:AuthoringConditionAction.java

示例9: removeQuestionReference

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Remove assessment question from HttpSession list and update page display. As authoring rule, all persist only
    * happen when user submit whole page. So this remove is just impact HttpSession values.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeQuestionReference(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
updateQuestionReferencesGrades(request, sessionMap, false);

int questionReferenceIdx = NumberUtils
	.toInt(request.getParameter(AssessmentConstants.PARAM_QUESTION_REFERENCE_INDEX), -1);
if (questionReferenceIdx != -1) {
    SortedSet<QuestionReference> questionReferences = getQuestionReferences(sessionMap);
    List<QuestionReference> rList = new ArrayList<QuestionReference>(questionReferences);
    QuestionReference questionReference = rList.remove(questionReferenceIdx);
    questionReferences.clear();
    questionReferences.addAll(rList);
    // add to delList
    List<QuestionReference> delList = getDeletedQuestionReferences(sessionMap);
    delList.add(questionReference);
}

reinitializeAvailableQuestions(sessionMap);

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

示例10: removeCondition

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Remove taskList item from HttpSession list and update page display. As authoring rule, all persist only happen
    * when user submit whole page. So this remove is just impact HttpSession values.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ChatConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);

int orderId = NumberUtils.stringToInt(request.getParameter(ChatConstants.PARAM_ORDER_ID), -1);
if (orderId != -1) {
    SortedSet<ChatCondition> conditionSet = getChatConditionSet(sessionMap);
    List<ChatCondition> conditionList = new ArrayList<ChatCondition>(conditionSet);
    ChatCondition condition = conditionList.remove(orderId);
    for (ChatCondition otherCondition : conditionSet) {
	if (otherCondition.getOrderId() > orderId) {
	    otherCondition.setOrderId(otherCondition.getOrderId() - 1);
	}
    }
    conditionSet.clear();
    conditionSet.addAll(conditionList);
    // add to delList
    List delList = getDeletedChatConditionList(sessionMap);
    delList.add(condition);
}

request.setAttribute(ChatConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ChatConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:AuthoringChatConditionAction.java

示例11: switchItem

import java.util.SortedSet; //导入方法依赖的package包/类
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, KalturaConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
request.setAttribute(KalturaConstants.ATTR_SESSION_MAP_ID, sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(KalturaConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<KalturaItem> kalturaList = getItemList(sessionMap);
    List<KalturaItem> rList = new ArrayList<KalturaItem>(kalturaList);
    // get current and the target item, and switch their sequnece
    KalturaItem item = rList.get(itemIdx);
    KalturaItem repItem;
    if (up) {
	repItem = rList.get(--itemIdx);
    } else {
	repItem = rList.get(++itemIdx);
    }
    int upSeqId = repItem.getSequenceId();
    repItem.setSequenceId(item.getSequenceId());
    item.setSequenceId(upSeqId);

    // put back list, it will be sorted again
    kalturaList.clear();
    kalturaList.addAll(rList);
}

return mapping.findForward(KalturaConstants.ITEM_LIST);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:AuthoringAction.java

示例12: cleanOldLogs

import java.util.SortedSet; //导入方法依赖的package包/类
private void cleanOldLogs(SortedSet<String> wals, String key, String id) {
  SortedSet<String> walSet = wals.headSet(key);
  LOG.debug("Removing " + walSet.size() + " logs in the list: " + walSet);
  for (String wal : walSet) {
    this.replicationQueues.removeLog(id, wal);
  }
  walSet.clear();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:ReplicationSourceManager.java

示例13: removeCondition

import java.util.SortedSet; //导入方法依赖的package包/类
/**
    * Remove taskList item from HttpSession list and update page display. As authoring rule, all persist only happen
    * when user submit whole page. So this remove is just impact HttpSession values.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);

int sequenceId = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_SEQUENCE_ID), -1);
if (sequenceId != -1) {
    SortedSet<TaskListCondition> conditionList = getTaskListConditionList(sessionMap);
    List<TaskListCondition> rList = new ArrayList<TaskListCondition>(conditionList);
    TaskListCondition condition = rList.remove(sequenceId);
    for (TaskListCondition otherCondition : conditionList) {
	if (otherCondition.getSequenceId() > sequenceId) {
	    otherCondition.setSequenceId(otherCondition.getSequenceId() - 1);
	}
    }
    conditionList.clear();
    conditionList.addAll(rList);
    // add to delList
    List delList = getDeletedTaskListConditionList(sessionMap);
    delList.add(condition);
}

request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(TaskListConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:AuthoringTaskListConditionAction.java

示例14: switchItem

import java.util.SortedSet; //导入方法依赖的package包/类
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ImageGalleryConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);

int imageIdx = NumberUtils.stringToInt(request.getParameter(ImageGalleryConstants.PARAM_IMAGE_INDEX), -1);
if (imageIdx != -1) {
    SortedSet<ImageGalleryItem> taskListList = getImageList(sessionMap);
    List<ImageGalleryItem> rList = new ArrayList<ImageGalleryItem>(taskListList);
    // get current and the target item, and switch their sequnece
    ImageGalleryItem image = rList.get(imageIdx);
    ImageGalleryItem repImage;
    if (up) {
	repImage = rList.get(--imageIdx);
    } else {
	repImage = rList.get(++imageIdx);
    }
    int upSeqId = repImage.getSequenceId();
    repImage.setSequenceId(image.getSequenceId());
    image.setSequenceId(upSeqId);

    // put back list, it will be sorted again
    taskListList.clear();
    taskListList.addAll(rList);
}

request.setAttribute(ImageGalleryConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ImageGalleryConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:AuthoringAction.java

示例15: handleAttributesSubtree

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Returns the Attr[]s to be output for the given element.
 * <br>
 * The code of this method is a copy of {@link #handleAttributes(Element,
 * NameSpaceSymbTable)},
 * whereas it takes into account that subtree-c14n is -- well -- subtree-based.
 * So if the element in question isRoot of c14n, it's parent is not in the
 * node set, as well as all other ancestors.
 *
 * @param element
 * @param ns
 * @return the Attr[]s to be output
 * @throws CanonicalizationException
 */
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
    throws CanonicalizationException {
    if (!element.hasAttributes() && !firstCall) {
        return null;
    }
    // result will contain the attrs which have to be output
    final SortedSet<Attr> result = this.result;
    result.clear();

    if (element.hasAttributes()) {
        NamedNodeMap attrs = element.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr attribute = (Attr) attrs.item(i);
            String NUri = attribute.getNamespaceURI();
            String NName = attribute.getLocalName();
            String NValue = attribute.getValue();

            if (!XMLNS_URI.equals(NUri)) {
                //It's not a namespace attr node. Add to the result and continue.
                result.add(attribute);
            } else if (!(XML.equals(NName) && XML_LANG_URI.equals(NValue))) {
                //The default mapping for xml must not be output.
                Node n = ns.addMappingAndRender(NName, NValue, attribute);

                if (n != null) {
                    //Render the ns definition
                    result.add((Attr)n);
                    if (C14nHelper.namespaceIsRelative(attribute)) {
                        Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
                        throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs
                        );
                    }
                }
            }
        }
    }

    if (firstCall) {
        //It is the first node of the subtree
        //Obtain all the namespaces defined in the parents, and added to the output.
        ns.getUnrenderedNodes(result);
        //output the attributes in the xml namespace.
        xmlattrStack.getXmlnsAttr(result);
        firstCall = false;
    }

    return result.iterator();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:Canonicalizer20010315.java


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