本文整理汇总了Java中java.util.SortedSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSet.add方法的具体用法?Java SortedSet.add怎么用?Java SortedSet.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SortedSet
的用法示例。
在下文中一共展示了SortedSet.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: if
import java.util.SortedSet; //导入方法依赖的package包/类
private SortedSet<R> getMore$(D prev, int limit, boolean minFirst, boolean drop) {
final SortedSet<R> result;
if (minFirst) {
result = new TreeSet<>(comparatorIncrement);
} else {
result = new TreeSet<>(comparatorDecrement);
}
R range = prev == null ? null : create(prev, prev);
int count = 0;
synchronized (this) { // 必须线程安全,否则rp参数可能无法被正确评估。
while (count < limit) {
range = getSerial$(range, limit - count, minFirst);
if (range == null) break;
else if (drop) drop(range);
result.add(range);
count += range.delta() + 1;
}
}
return result;
}
示例2: testConstructor
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Tests, if all class members are set correctly by the constructor.
*/
@Test
public final void testConstructor() {
SortedSet<ItemSet<NamedItem>> frequentItemSets = new FrequentItemSets<>(
Comparator.reverseOrder());
ItemSet<NamedItem> itemSet1 = new ItemSet<>();
itemSet1.add(new NamedItem("a"));
itemSet1.setSupport(0.5);
ItemSet<NamedItem> itemSet2 = new ItemSet<>();
itemSet2.add(new NamedItem("b"));
itemSet2.setSupport(0.6);
frequentItemSets.add(itemSet1);
frequentItemSets.add(itemSet2);
assertEquals(2, frequentItemSets.size());
assertEquals(itemSet2, frequentItemSets.first());
assertEquals(itemSet1, frequentItemSets.last());
}
示例3: valuesGivenInJsonShouldBeTrimmedToNull
import java.util.SortedSet; //导入方法依赖的package包/类
@Test
public void valuesGivenInJsonShouldBeTrimmedToNull() {
final SortedSet<String> tags = new TreeSet<>();
tags.add("");
tags.add(" tag");
tags.add("\tTaggy McTagface\t");
final Integration integration = new Integration.Builder().id(id).name(" some-name\t").description("")
.tags(tags).desiredStatus(Integration.Status.Draft).build();
post("/api/v1/integrations", integration, Integration.class);
final ResponseEntity<Integration> result = get("/api/v1/integrations/" + id, Integration.class);
final Integration created = result.getBody();
assertThat(created.getName()).isEqualTo("some-name");
assertThat(created.getDescription()).isNotPresent();
assertThat(created.getTags()).containsExactly("Taggy McTagface", "tag");
}
示例4: getVersions
import java.util.SortedSet; //导入方法依赖的package包/类
public SortedSet<WebVersion> getVersions()
{
final SortedSet<WebVersion> versions = new TreeSet<WebVersion>(Utils.VERSION_COMPARATOR);
final File upgradeFolder = config.getUpdatesDir();
if( upgradeFolder.exists() )
{
for( String file : upgradeFolder.list() )
{
if( file != null && Utils.VERSION_EXTRACT.matcher(file).matches() )
{
versions.add(getWebVersionFromFile(file));
}
}
}
else
{
throw new RuntimeException("No upgrades folder found");
}
return versions;
}
示例5: buildReportsData
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public List<ReportChartModel> buildReportsData(String data, ReportCompareField compareField,
Map<String, String> filters)
throws Exception {
List<Report> reports = constructReportList(data);
if (reports != null) {
List<ReportChartModel> reportData = new ArrayList<>(reports.size());
SortedSet<String> tSet = new TreeSet<>();
for (Report report : reports) {
ReportChartModel m = new ReportChartModel();
m.label = getReportLabel(filters, report);
tSet.add(m.label);
m.value = getReportValues(report, compareField);
reportData.add(m);
}
if (reportData.size() > 0) {
return fillChartData(reportData, tSet, filters);
} else {
return reportData;
}
}
return null;
}
示例6: getFields
import java.util.SortedSet; //导入方法依赖的package包/类
private Set<String> getFields(Object instance) {
SortedSet<String> output = new TreeSet<>();
//determine fields declared in this class only (no fields of superclass)
Field[] fields = instance.getClass().getDeclaredFields();
//print field names paired with their values
for (Field field : fields) {
output.add(field.getName());
}
return output;
}
示例7: getEmailProgressDates
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Gets learners or monitors of the lesson and organisation containing it.
*
* @throws SchedulerException
*/
public ActionForward getEmailProgressDates(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, JSONException, SchedulerException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
return null;
}
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
JSONObject responseJSON = new JSONObject();
JSONArray datesJSON = new JSONArray();
// find all the current dates set up to send the emails
Scheduler scheduler = getScheduler();
String triggerPrefix = getTriggerPrefix(lessonId);
SortedSet<Date> currentDatesSet = new TreeSet<Date>();
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.startsWith(triggerPrefix)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
// get only the trigger for the current lesson
Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
if (lessonId.equals(jobLessonId)) {
Date triggerDate = trigger.getNextFireTime();
currentDatesSet.add(triggerDate);
}
}
}
for (Date date : currentDatesSet) {
datesJSON.put(createDateJSON(request.getLocale(), user, date, null));
}
responseJSON.put("dates", datesJSON);
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(responseJSON.toString());
return null;
}
示例8: addDefaultFields
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Any fields that are in otherFields but not in myFields are added to myFields as defaults. When
* adding fields they are inserted in the natural sort order. Note: myFields may be modified by
* this call.
*/
private static void addDefaultFields(SortedSet<PdxField> myFields,
SortedSet<PdxField> otherFields) {
for (PdxField f : otherFields) {
if (!myFields.contains(f)) {
myFields.add(new DefaultPdxField(f));
}
}
}
示例9: complete
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
SortedSet<String> strings = delegate.getStrings();
for (Icmp6Code code : Icmp6Code.values()) {
strings.add(code.toString());
}
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(buffer, cursor, candidates);
}
示例10: verifyRequirementsEnabled
import java.util.SortedSet; //导入方法依赖的package包/类
private final void verifyRequirementsEnabled(final String tags, final String... expectedChartNames) {
assertNotNull(tags);
assertNotNull(expectedChartNames);
final Config.Builder configBuilder = Config.newBuilder();
assertNotNull(configBuilder);
configBuilder.setRaw(tags);
final SortedSet<String> expectations = new TreeSet<>();
for (final String expectation : expectedChartNames) {
assertNotNull(expectation);
expectations.add(expectation);
}
verifyRequirementsEnabled(configBuilder, expectations);
}
示例11: initOverallFeedback
import java.util.SortedSet; //导入方法依赖的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 initOverallFeedback(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
.getAttribute(sessionMapID);
AssessmentForm assessmentForm = (AssessmentForm) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT_FORM);
Assessment assessment = assessmentForm.getAssessment();
// initial Overall feedbacks list
SortedSet<AssessmentOverallFeedback> overallFeedbackList = new TreeSet<AssessmentOverallFeedback>(
new SequencableComparator());
if (!assessment.getOverallFeedbacks().isEmpty()) {
overallFeedbackList.addAll(assessment.getOverallFeedbacks());
} else {
for (int i = 1; i <= AssessmentConstants.INITIAL_OVERALL_FEEDBACK_NUMBER; i++) {
AssessmentOverallFeedback overallFeedback = new AssessmentOverallFeedback();
if (i == 1) {
overallFeedback.setGradeBoundary(100);
}
overallFeedback.setSequenceId(i);
overallFeedbackList.add(overallFeedback);
}
}
request.setAttribute(AssessmentConstants.ATTR_OVERALL_FEEDBACK_LIST, overallFeedbackList);
return mapping.findForward(AssessmentConstants.SUCCESS);
}
示例12: getServiceProviderDomains
import java.util.SortedSet; //导入方法依赖的package包/类
private static SortedSet<URI> getServiceProviderDomains(final ServiceProvider serviceProvider)
{
final SortedSet<URI> domains = new TreeSet<URI>();
if (serviceProvider!=null) {
final Service [] services = serviceProvider.getServices();
for (final Service service : services)
{
final URI domain = service.getDomain();
domains.add(domain);
}
}
return domains;
}
示例13: testSeveral_serialization
import java.util.SortedSet; //导入方法依赖的package包/类
@GwtIncompatible // SerializableTester
public void testSeveral_serialization() {
SortedSet<String> set = new SafeTreeSet<String>();
set.add("a");
set.add("b");
set.add("c");
SortedSet<String> copy = SerializableTester.reserializeAndAssert(set);
assertEquals(set.comparator(), copy.comparator());
}
示例14: extractFormToForumCondition
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Extract form content to ForumCondition.
*
* @param request
* @param form
* @throws Exception
*/
private void extractFormToForumCondition(HttpServletRequest request, ForumConditionForm form) throws Exception {
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID());
// check whether it is "edit(old item)" or "add(new item)"
SortedSet<ForumCondition> conditionSet = getForumConditionSet(sessionMap);
int orderId = form.getOrderId();
ForumCondition condition = null;
if (orderId == -1) { // add
String properConditionName = getForumService().createTextSearchConditionName(conditionSet);
condition = form.extractCondition();
condition.setName(properConditionName);
int maxOrderId = 1;
if (conditionSet != null && conditionSet.size() > 0) {
ForumCondition last = conditionSet.last();
maxOrderId = last.getOrderId() + 1;
}
condition.setOrderId(maxOrderId);
conditionSet.add(condition);
} else { // edit
List<ForumCondition> conditionList = new ArrayList<ForumCondition>(conditionSet);
condition = conditionList.get(orderId - 1);
form.extractCondition(condition);
}
Long[] selectedItems = form.getSelectedItems();
Set<Message> conditionTopics = new TreeSet<Message>(new ConditionTopicComparator());
Set<MessageDTO> messageDTOs = getMessageDTOList(sessionMap);
for (Long selectedItem : selectedItems) {
for (MessageDTO messageDTO : messageDTOs) {
Message topic = messageDTO.getMessage();
if (selectedItem.equals(topic.getCreated().getTime())) {
conditionTopics.add(topic);
}
}
}
condition.setTopics(conditionTopics);
}
示例15: addQuestionReference
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 addQuestionReference(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);
SortedSet<QuestionReference> references = getQuestionReferences(sessionMap);
int questionIdx = NumberUtils.toInt(request.getParameter(AssessmentConstants.PARAM_QUESTION_INDEX), -1);
// set SequenceId
QuestionReference reference = new QuestionReference();
int maxSeq = 1;
if ((references != null) && (references.size() > 0)) {
QuestionReference last = references.last();
maxSeq = last.getSequenceId() + 1;
}
reference.setSequenceId(maxSeq);
// set isRandomQuestion
boolean isRandomQuestion = (questionIdx == -1);
reference.setRandomQuestion(isRandomQuestion);
if (isRandomQuestion) {
reference.setDefaultGrade(1);
} else {
SortedSet<AssessmentQuestion> questionList = getQuestionList(sessionMap);
AssessmentQuestion question = null;
for (AssessmentQuestion questionFromList : questionList) {
if (questionFromList.getSequenceId() == questionIdx) {
question = questionFromList;
break;
}
}
reference.setQuestion(question);
reference.setDefaultGrade(question.getDefaultGrade());
}
references.add(reference);
reinitializeAvailableQuestions(sessionMap);
request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(AssessmentConstants.SUCCESS);
}