List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:net.sourceforge.fenixedu.domain.credits.util.DepartmentCreditsPoolBean.java
private void addToSet(SortedSet<DepartmentExecutionCourse> set, ExecutionCourse executionCourse) { DepartmentExecutionCourse departmentExecutionCourse = new DepartmentExecutionCourse(executionCourse); set.add(departmentExecutionCourse); final BigDecimal departmentEffectiveLoad = departmentExecutionCourse.getDepartmentEffectiveLoad(); final BigDecimal unitCreditValue = executionCourse.getUnitCreditValue(); if (departmentEffectiveLoad != null && unitCreditValue != null) { assignedCredits = assignedCredits.add(departmentEffectiveLoad.multiply(unitCreditValue)); }//from w w w . j av a2 s. c om }
From source file:gov.nih.nci.caarray.application.fileaccess.FileAccessServiceBean.java
private void removeFile(CaArrayFile caArrayFile) { // A hibernate bug is preventing us from simply calling caArrayFile.getProject().getFiles().remove(caArrayFile) // https://hibernate.onjira.com/browse/HHH-3799 // The workaround is to clear the collection and re-add everything we don't want to delete. // This is in reference to issue ARRAY-2349. SortedSet<CaArrayFile> files = caArrayFile.getProject().getFiles(); SortedSet<CaArrayFile> filesToKeep = new TreeSet<CaArrayFile>(); Long fileId = caArrayFile.getId(); for (CaArrayFile file : files) { if (!file.getId().equals(fileId)) { filesToKeep.add(file); }//from ww w .j a va 2s . c o m } files.clear(); files.addAll(filesToKeep); this.fileDao.remove(caArrayFile); }
From source file:net.ripe.rpki.commons.crypto.crl.X509Crl.java
public SortedSet<Entry> getRevokedCertificates() { SortedSet<Entry> result = new TreeSet<Entry>(); Set<? extends X509CRLEntry> entries = getCrl().getRevokedCertificates(); if (entries != null) { for (X509CRLEntry entry : entries) { result.add(new Entry(entry)); }//from w ww . j a va 2 s . c o m } return result; }
From source file:com.edmunds.etm.loadbalancer.impl.LoadBalancerController.java
private SortedSet<PoolMember> vipToPoolMembers(ManagementVip vip) { Collection<ManagementPoolMember> managementPoolMembers = vip.getPoolMembers().values(); SortedSet<PoolMember> poolMembers = Sets.newTreeSet(); for (ManagementPoolMember mpm : managementPoolMembers) { poolMembers.add(new PoolMember(mpm.getHostAddress())); }/*from ww w . jav a2s.co m*/ return poolMembers; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.department.PublicDepartmentSiteDA.java
private void addListTeacher(Map<String, SortedSet<Teacher>> teachersMap, String key, Teacher teacher) { SortedSet<Teacher> teachers = teachersMap.get(key); if (teachers == null) { teachers = new TreeSet<Teacher>(Teacher.TEACHER_COMPARATOR_BY_CATEGORY_AND_NUMBER); teachersMap.put(key, teachers);/* w w w . j av a 2 s. co m*/ } teachers.add(teacher); }
From source file:de.fhg.igd.mapviewer.view.MapTools.java
/** * @see ContributionItem#fill(ToolBar, int) */// w ww . j ava 2 s.co m @Override public void fill(ToolBar parent, int index) { // get map tool configurations IConfigurationElement[] config = Platform.getExtensionRegistry() .getConfigurationElementsFor(MapTool.class.getName()); SortedSet<AbstractMapTool> sortedTools = new TreeSet<AbstractMapTool>(); boolean defFound = false; for (IConfigurationElement element : config) { AbstractMapTool tool = createMapTool(element); if (tool != null) { sortedTools.add(tool); if (tool.getId().equals(defTool)) { defFound = true; } tools.put(tool.getId(), tool); } } boolean first = true; for (AbstractMapTool tool : sortedTools) { boolean def = (first && !defFound) || (defFound && tool.getId().equals(defTool)); MapToolAction action = new MapToolAction(tool, mapKit, def); tips.createItem(action).fill(parent, index++); first = false; } dirty = false; }
From source file:org.openmrs.web.controller.maintenance.SettingsController.java
@ModelAttribute(SECTIONS) public List<String> getSections() { SortedSet<String> sortedSections = new TreeSet<String>(); List<GlobalProperty> globalProperties = getService().getAllGlobalProperties(); for (GlobalProperty globalProperty : globalProperties) { SettingsProperty property = new SettingsProperty(globalProperty); if (!isHidden(property)) { sortedSections.add(property.getSection()); }// w w w .ja v a 2s .co m } List<String> sections = new ArrayList<String>(); if (sortedSections.remove(SettingsProperty.GENERAL)) { sections.add(SettingsProperty.GENERAL); } sections.addAll(sortedSections); return sections; }
From source file:org.ngrinder.perftest.service.TagService.java
/** * Add tags./* w w w . jav a 2 s.c o m*/ * * @param user user * @param tags tag string list * @return inserted tags */ @Transactional public SortedSet<Tag> addTags(User user, String[] tags) { if (ArrayUtils.isEmpty(tags)) { return new TreeSet<Tag>(); } Specifications<Tag> spec = Specifications.where(lastModifiedOrCreatedBy(user)).and(valueIn(tags)); List<Tag> foundTags = tagRepository.findAll(spec); SortedSet<Tag> allTags = new TreeSet<Tag>(foundTags); for (String each : tags) { Tag newTag = new Tag(StringUtils.trimToEmpty(StringUtils.replace(each, ",", ""))); if (allTags.contains(newTag)) { continue; } if (!foundTags.contains(newTag) && !allTags.contains(newTag)) { allTags.add(saveTag(user, newTag)); } } return allTags; }
From source file:com.puppycrawl.tools.checkstyle.checks.TranslationCheck.java
/** * Helper method to log an io exception. * @param ex the exception that occurred * @param file the file that could not be processed *//*from w ww. ja v a 2s.co m*/ private void logIOException(IOException ex, File file) { String[] args = null; String key = "general.fileNotFound"; if (!(ex instanceof FileNotFoundException)) { args = new String[] { ex.getMessage() }; key = "general.exception"; } final LocalizedMessage message = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, key, args, getId(), getClass(), null); final SortedSet<LocalizedMessage> messages = Sets.newTreeSet(); messages.add(message); getMessageDispatcher().fireErrors(file.getPath(), messages); LOG.debug("IOException occurred.", ex); }
From source file:com.cloudera.oryx.kmeans.computation.cluster.KSketchIndex.java
public Distance getDistance(RealVector vec, int id, boolean approx) { double distance = Double.POSITIVE_INFINITY; int closestPoint = -1; if (approx) { if (updated) { rebuildIndices();/*from www . j a v a2 s . co m*/ } BitSet q = index(vec); List<BitSet> index = indices.get(id); SortedSet<Idx> lookup = Sets.newTreeSet(); for (int j = 0; j < index.size(); j++) { Idx idx = new Idx(hammingDistance(q, index.get(j)), j); if (lookup.size() < projectionSamples) { lookup.add(idx); } else if (idx.compareTo(lookup.last()) < 0) { lookup.add(idx); lookup.remove(lookup.last()); } } List<RealVector> p = points.get(id); List<Double> lsq = lengthSquared.get(id); for (Idx idx : lookup) { double lenSq = lsq.get(idx.getIndex()); double length = vec.getNorm(); double d = length * length + lenSq - 2 * vec.dotProduct(p.get(idx.getIndex())); if (d < distance) { distance = d; closestPoint = idx.getIndex(); } } } else { // More expensive exact computation List<RealVector> px = points.get(id); List<Double> lsq = lengthSquared.get(id); for (int j = 0; j < px.size(); j++) { RealVector p = px.get(j); double lenSq = lsq.get(j); double length = vec.getNorm(); double d = length * length + lenSq - 2 * vec.dotProduct(p); if (d < distance) { distance = d; closestPoint = j; } } } return new Distance(distance, closestPoint); }