本文整理匯總了Java中java.util.TreeSet.add方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeSet.add方法的具體用法?Java TreeSet.add怎麽用?Java TreeSet.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.TreeSet
的用法示例。
在下文中一共展示了TreeSet.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: expandMethodLevelCluster2Bodies
import java.util.TreeSet; //導入方法依賴的package包/類
private TreeSet<LSDFact> expandMethodLevelCluster2Bodies (PrintStream p, List<LSDFact> methodLevelCluster) {
TreeSet<LSDFact> ontheflyDeltaKB = new TreeSet<LSDFact>();
TreeSet<String> methodConstants = null;
if (methodLevelCluster!=null) {
methodConstants= new TreeSet<String>();
for (LSDFact methodF: methodLevelCluster) {
methodConstants.add(methodF.getBindings().get(0).getGroundConst());
}
}
for (LSDFact fact:originalDeltaKB) {
String involvedMethod =null;
if (fact.getPredicate().getName().indexOf("_calls")>0) {
involvedMethod= fact.getBindings().get(0).getGroundConst();
}
else if (fact.getPredicate().getName().indexOf("_accesses")>0) {
involvedMethod = fact.getBindings().get(1).getGroundConst();
}
if (involvedMethod!=null && (methodConstants==null || methodConstants.contains(involvedMethod))){
if (p!=null) p.println("\t\t\t"+ fact);
ontheflyDeltaKB.add(fact);
}
}
return ontheflyDeltaKB;
}
示例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);
}
示例4: removeStopWordsRemoveAll
import java.util.TreeSet; //導入方法依賴的package包/類
public static void removeStopWordsRemoveAll(String text){
//******************EXAMPLE WITH REMOVE ALL *******************************************************************************************
try {
out.println(text);
Scanner stopWordList = new Scanner(new File("C://Jenn Personal//Packt Data Science//Chapter 3 Data Cleaning//stopwords.txt"));
TreeSet<String> stopWords = new TreeSet<String>();
while(stopWordList.hasNextLine()){
stopWords.add(stopWordList.nextLine());
}
ArrayList<String> dirtyText = new ArrayList<String>(Arrays.asList(text.split(" ")));
dirtyText.removeAll(stopWords);
out.println("Clean words: ");
for(String x : dirtyText){
out.print(x + " ");
}
out.println();
stopWordList.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例5: 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;
}
}
示例6: testDirector
import java.util.TreeSet; //導入方法依賴的package包/類
private static void testDirector(ModelPerformer[] performers) throws Exception
{
final TreeSet<Integer> played = new TreeSet<Integer>();
ModelDirectedPlayer player = new ModelDirectedPlayer()
{
public void play(int performerIndex,
ModelConnectionBlock[] connectionBlocks) {
played.add(performerIndex);
}
};
ModelStandardIndexedDirector idirector =
new ModelStandardIndexedDirector(performers, player);
ModelStandardDirector director =
new ModelStandardDirector(performers, player);
for (int n = 0; n < 128; n++)
{
for (int v = 0; v < 128; v++)
{
director.noteOn(n, v);
String p1 = treeToString(played);
played.clear();
idirector.noteOn(n, v);
String p2 = treeToString(played);
played.clear();
if(!p1.equals(p2))
throw new Exception(
"Note = " + n + ", Vel = " + v + " failed");
}
}
}
示例7: getOverallFeedbacksFromRequest
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Get overall feedbacks from <code>HttpRequest</code>
*
* @param request
*/
private TreeSet<AssessmentOverallFeedback> getOverallFeedbacksFromRequest(HttpServletRequest request,
boolean skipBlankOverallFeedbacks) {
int count = NumberUtils.toInt(request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_COUNT));
TreeSet<AssessmentOverallFeedback> overallFeedbackList = new TreeSet<AssessmentOverallFeedback>(
new SequencableComparator());
for (int i = 0; i < count; i++) {
String gradeBoundaryStr = request
.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_GRADE_BOUNDARY_PREFIX + i);
String feedback = request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_FEEDBACK_PREFIX + i);
String sequenceId = request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_SEQUENCE_ID_PREFIX + i);
if ((StringUtils.isBlank(feedback) || StringUtils.isBlank(gradeBoundaryStr)) && skipBlankOverallFeedbacks) {
continue;
}
AssessmentOverallFeedback overallFeedback = new AssessmentOverallFeedback();
overallFeedback.setSequenceId(NumberUtils.toInt(sequenceId));
if (!StringUtils.isBlank(gradeBoundaryStr)) {
int gradeBoundary = NumberUtils.toInt(
request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_GRADE_BOUNDARY_PREFIX + i));
overallFeedback.setGradeBoundary(gradeBoundary);
}
overallFeedback.setFeedback(feedback);
overallFeedbackList.add(overallFeedback);
}
return overallFeedbackList;
}
示例8: DistributionConflict
import java.util.TreeSet; //導入方法依賴的package包/類
protected DistributionConflict(DistributionPref pref, org.unitime.timetable.model.Exam exclude) {
iPref = pref;
iId = pref.getUniqueId();
iType = pref.getDistributionType().getLabel();
iOtherExams = new TreeSet();
for (Iterator i=pref.getDistributionObjects().iterator();i.hasNext();) {
DistributionObject dObj = (DistributionObject)i.next();
org.unitime.timetable.model.Exam exam = (org.unitime.timetable.model.Exam)dObj.getPrefGroup();
if (exam.equals(exclude)) continue;
iOtherExams.add(exam.getAssignedPeriod()==null?new ExamInfo(exam):new ExamAssignment(exam));
}
iPreference = pref.getPrefLevel().getPrefProlog();
}
示例9: handleKeySet
import java.util.TreeSet; //導入方法依賴的package包/類
@Override
protected Set<String> handleKeySet() {
ICUResourceBundleReader reader = wholeBundle.reader;
TreeSet<String> keySet = new TreeSet<String>();
ICUResourceBundleReader.Table table = (ICUResourceBundleReader.Table)value;
for (int i = 0; i < table.getSize(); ++i) {
keySet.add(table.getKey(reader, i));
}
return keySet;
}
示例10: sessionsCanManage
import java.util.TreeSet; //導入方法依賴的package包/類
public Set sessionsCanManage(){
TreeSet sessions = new TreeSet();
Department dept = null;
for(Iterator it = getDepartments().iterator(); it.hasNext();){
dept = (Department) it.next();
sessions.add(dept.getSession());
}
return(sessions);
}
示例11: getUniqueStationName
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Returns given name if a station with the same name does not exists or makes it unique
* @param name station name
* @return unique name
*/
private String getUniqueStationName(String name) {
TreeSet<String> names = new TreeSet<String>(); // Map of all unique names with their first users
Vector keys = getStationKeys();
// Finds all used names
for (int i = 0; i < keys.size(); i++) {
names.add(this.getStationName(keys.get(i)));
}
// If name is new, returns it
if (!names.contains(name)) {
return name;
}
int num;
// If format is already '*_[number]' increment number
char[] charname = name.toCharArray();
int n = charname.length - 1;
while (charname[n] >= '0' && charname[n] <= '9' && n > 0) {
n--;
}
if (charname[n] == '_') {
num = Integer.parseInt(name.substring(n + 1));
name = name.substring(0, n); // Removes suffix
}
// Otherwise uses number 1
else {
num = 1;
}
// Finds unique number
while (names.contains(name + "_" + num)) {
num++;
}
return name + "_" + num;
}
示例12: get
import java.util.TreeSet; //導入方法依賴的package包/類
public TreeSet<TimeBlock> get(Long roomPermId, String excludeType) {
TreeSet<TimeBlock> roomAvailability = iAvailability.get(roomPermId);
if (roomAvailability==null || excludeType==null || excludeType.equals(iExcludeType)) return roomAvailability;
TreeSet<TimeBlock> ret = new TreeSet();
for (TimeBlock block : roomAvailability) {
if (excludeType.equals(block.getEventType())) continue;
ret.add(block);
}
return ret;
}
示例13: showScheduledEmails
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Renders a page listing all scheduled emails.
*/
public ActionForward showScheduledEmails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, SchedulerException {
getUserManagementService();
Scheduler scheduler = getScheduler();
TreeSet<EmailScheduleMessageJobDTO> scheduleList = new TreeSet<EmailScheduleMessageJobDTO>();
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
boolean isLessonNotifications = (lessonId != null);
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
if (isLessonNotifications) {
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(),
"show scheduled lesson email notifications", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the lesson");
return null;
}
} else {
if (!getSecurityService().isGroupMonitor(organisationId, getCurrentUser().getUserID(),
"show scheduled course email notifications", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the organisation");
return null;
}
}
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.startsWith(EmailNotificationsAction.TRIGGER_PREFIX_NAME)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
// filter triggers
if (isLessonNotifications) {
Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
if ((jobLessonId == null) || (!lessonId.equals(jobLessonId))) {
continue;
}
} else {
Object jobOrganisationId = jobDataMap.get(AttributeNames.PARAM_ORGANISATION_ID);
if ((jobOrganisationId == null) || (!organisationId.equals(jobOrganisationId))) {
continue;
}
}
Date triggerDate = trigger.getNextFireTime();
String emailBody = WebUtil.convertNewlines((String) jobDataMap.get("emailBody"));
int searchType = (Integer) jobDataMap.get("searchType");
EmailScheduleMessageJobDTO emailScheduleJobDTO = new EmailScheduleMessageJobDTO();
emailScheduleJobDTO.setTriggerName(triggerName);
emailScheduleJobDTO.setTriggerDate(triggerDate);
emailScheduleJobDTO.setEmailBody(emailBody);
emailScheduleJobDTO.setSearchType(searchType);
scheduleList.add(emailScheduleJobDTO);
}
}
request.setAttribute("scheduleList", scheduleList);
request.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId);
request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId);
return mapping.findForward("scheduledEmailList");
}
示例14: cnbs
import java.util.TreeSet; //導入方法依賴的package包/類
private static Set<String> cnbs(Set<Module> modules) {
TreeSet<String> set = new TreeSet<String>();
for (Module m : modules) {
set.add(m.getCodeNameBase());
}
return set;
}
示例15: printFieldOfType
import java.util.TreeSet; //導入方法依賴的package包/類
private void printFieldOfType (PrintStream p, TreeSet<LSDFact> ontheflyDeltaKB, LSDFact fieldF) {
for (LSDFact fact:originalDeltaKB) {
if (fact.getPredicate().getName().indexOf("_fieldoftype")>0 && fact.getBindings().get(0).getGroundConst().equals(fieldF.getBindings().get(0).getGroundConst())){
if (filter.fieldLevel) ontheflyDeltaKB.add(fact);
if (filter.fieldLevel && p!=null) p.println("\t\t\t"+ fact);
}
}
}