List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:gov.nih.nci.caarray.application.arraydesign.AbstractArrayDesignServiceTest.java
public ArrayDesign createDesign(Organization provider, Organism organism, SortedSet<AssayType> assayTypes, CaArrayFile caArrayFile) {/* w w w. ja va 2s.c o m*/ final ArrayDesign arrayDesign = new ArrayDesign(); arrayDesign.setName("Dummy Design"); if (provider == null) { provider = DUMMY_ORGANIZATION; } arrayDesign.setProvider(provider); if (organism == null) { organism = DUMMY_ORGANISM; } arrayDesign.setOrganism(organism); if (assayTypes == null) { assayTypes = new TreeSet<AssayType>(); assayTypes.add(DUMMY_ASSAY_TYPE); } arrayDesign.setAssayTypes(assayTypes); if (caArrayFile == null) { caArrayFile = new CaArrayFile(); } this.fileAccessServiceStub.save(caArrayFile); arrayDesign.addDesignFile(caArrayFile); arrayDesign.setTechnologyType(DUMMY_TERM); return arrayDesign; }
From source file:edu.sdsc.scigraph.internal.reachability.ReachabilityIndex.java
/** * @return The hop coverage for each node sorted in descending order. *//*from w w w . ja va 2 s. c om*/ SortedSet<Entry<Long, Integer>> getHopCoverages(Predicate<Node> nodePredicate) { SortedSet<Entry<Long, Integer>> nodeSet = new TreeSet<Entry<Long, Integer>>( new Comparator<Entry<Long, Integer>>() { @Override public int compare(Entry<Long, Integer> a, Entry<Long, Integer> b) { int difference = b.getValue() - a.getValue(); return (0 != difference) ? difference : (int) (a.getKey() - b.getKey()); } }); try (Transaction tx = graphDb.beginTx()) { for (Node n : GlobalGraphOperations.at(graphDb).getAllNodes()) { if (n.getId() > 0) { int relationshipCount = nodePredicate.apply(n) ? size(n.getRelationships()) : -1; nodeSet.add(new AbstractMap.SimpleEntry<Long, Integer>(n.getId(), relationshipCount)); } } } return nodeSet; }
From source file:cerrla.LocalCrossEntropyDistribution.java
/** * Processes the internal goal (checks if it is achieved). * /*from w w w .j a v a 2 s . c o m*/ * @param modularPolicy * The policy that called this operation. * @param observations * The current state observations. * @param goalReplacements * The current goal replacement variable(s) (a -> ?G_0). * @return True if the internal goal is/has been achieved. */ private boolean processInternalGoal(ModularPolicy modularPolicy, RRLObservations observations, BidiMap goalReplacements) { if (modularPolicy.isGoalCurrentlyAchieved()) return true; // Form the goal rule if (!goalCondition_.isMainGoal()) { if (goalRule_ == null) { SortedSet<RelationalPredicate> conditions = new TreeSet<RelationalPredicate>(); conditions.add(goalCondition_.getFact()); goalRule_ = new RelationalRule(conditions, null, null, this); if (!goalRule_.isLegal()) System.err.println("Illegal goal condition: " + conditions); } } else goalRule_ = null; try { // Assign the parameters Rete state = observations.getState(); // System.out.println(StateSpec.extractFacts(state)); ValueVector vv = new ValueVector(); goalRule_.setParameters(goalReplacements); if (goalRule_.getParameters() != null) for (RelationalArgument param : goalRule_.getParameters()) vv.add(param.toString()); // Run the query String query = StateSpec.getInstance().getRuleQuery(goalRule_, false); QueryResult results = state.runQueryStar(query, vv); // If results, then the goal has been met! if (results.next()) { modularPolicy.setGoalAchieved(); } else { modularPolicy.setGoalUnachieved(true); } } catch (Exception e) { e.printStackTrace(); } return modularPolicy.isGoalCurrentlyAchieved(); }
From source file:edu.harvard.med.screensaver.model.libraries.Library.java
@Transient public SortedSet<LibraryPlate> getLibraryPlates() { SetMultimap<Integer, AssayPlate> index = HashMultimap.create(); for (Copy copy : getCopies()) { for (Map.Entry<Integer, Plate> entry : copy.getPlates().entrySet()) { index.putAll(entry.getKey(), entry.getValue().getAssayPlates()); }/*ww w . j av a2 s .c o m*/ } SortedSet<LibraryPlate> libraryPlates = Sets.newTreeSet(); Set<AssayPlate> assayPlates; for (int p = getStartPlate(); p <= getEndPlate(); ++p) { if (index.containsKey(p)) { assayPlates = index.get(p); } else { assayPlates = Collections.emptySet(); } libraryPlates.add(new LibraryPlate(p, this, assayPlates)); } return libraryPlates; }
From source file:edu.harvard.med.screensaver.model.screenresults.ScreenResult.java
private SortedSet<AssayPlate> findOrCreateAssayPlatesDataLoaded(int plateNumber, int replicatesDataLoaded) { SortedSet<AssayPlate> mostRecentAssayPlatesForPlateNumber = Sets.newTreeSet(); SortedSet<AssayPlate> allAssayPlatesForPlateNumber = getScreen().findAssayPlates(plateNumber); if (!allAssayPlatesForPlateNumber.isEmpty()) { final LibraryScreening lastLibraryScreening = ImmutableSortedSet .copyOf(Iterables.transform(allAssayPlatesForPlateNumber, AssayPlate.ToLibraryScreening)) .last();/*from ww w . jav a2 s . c o m*/ assert lastLibraryScreening != null; mostRecentAssayPlatesForPlateNumber .addAll(Sets.filter(allAssayPlatesForPlateNumber, new Predicate<AssayPlate>() { public boolean apply(AssayPlate ap) { return lastLibraryScreening.equals(ap.getLibraryScreening()); } })); } SortedSet<AssayPlate> assayPlatesDataLoaded = Sets.newTreeSet(); // if there are fewer assay plates screened replicates than we have data // for, then a library screening must not have been recorded for the assay // plates that were used to generate this data, so we'll create them now if (mostRecentAssayPlatesForPlateNumber.size() < replicatesDataLoaded) { //log.warn("creating missing assay plate(s) for plate number " + plateNumber); for (int r = 0; r < replicatesDataLoaded; r++) { assayPlatesDataLoaded.add(getScreen().createAssayPlate(plateNumber, r)); } } else { for (AssayPlate assayPlate : mostRecentAssayPlatesForPlateNumber) { if (assayPlate.getReplicateOrdinal() < replicatesDataLoaded) { assayPlatesDataLoaded.add(assayPlate); } } } return assayPlatesDataLoaded; }
From source file:net.contextfw.web.application.internal.servlet.UriMappingFactory.java
@SuppressWarnings("unchecked") public SortedSet<UriMapping> createMappings(Collection<Class<?>> origClasses, ClassLoader classLoader, InitializerProvider initializerProvider, InitHandler initHandler, PropertyProvider properties, RequestInvocationFilter filter) { // Note: This process creates some phantom chains from // views that do not have any url. Those chains are // however ingnored and are not such problem. SortedSet<UriMapping> mappings = new TreeSet<UriMapping>(); try {//from ww w . ja v a2s . c o m for (Class<?> origClass : origClasses) { Class<?> cl = classLoader.loadClass(origClass.getCanonicalName()); View annotation = cl.getAnnotation(View.class); if (annotation != null) { if (!Component.class.isAssignableFrom(cl)) { throw new WebApplicationException( "Class " + cl.getName() + " annotated with @View does " + "not extend Component"); } List<Class<? extends Component>> chain = initializerProvider.getInitializerChain(cl); InitServlet servlet = new InitServlet(initHandler, chain, filter); for (String url : annotation.url()) { if (!"".equals(url)) { mappings.add(this.getMapping((Class<? extends Component>) cl, servlet, url)); } } for (String property : annotation.property()) { if (!"".equals(property)) { if (!properties.get().containsKey(property)) { throw new WebApplicationException("No url bound to property: " + property); } String url = properties.get().getProperty(property); if (url != null && !"".equals(url)) { mappings.add(this.getMapping((Class<? extends Component>) cl, servlet, url)); } else { throw new WebApplicationException("No url bound to view component. (class=" + cl.getSimpleName() + ", property=" + property + ")"); } } } } } } catch (ClassNotFoundException e) { throw new WebApplicationException(e); } return mappings; }
From source file:com.atlassian.jira.user.util.UserUtilImpl.java
public SortedSet<Group> getGroupsForUser(final String userName) { notNull("userName", userName); final SortedSet<Group> setOfGroups = new TreeSet<Group>(); Iterable<Group> groups = getGroupsForUserFromCrowd(userName); for (Group group : groups) { setOfGroups.add(group); }/*from w w w .j a v a 2 s .co m*/ return Collections.unmodifiableSortedSet(setOfGroups); }
From source file:Arguments.java
/** * Gives a short synopsis of how to provide arguments, including which are required and optional, * and which long arguments take values. */// w ww . ja va2s . co m public String getUsage() { StringBuilder buf = new StringBuilder(); if (programName.length() > 0) { buf.append(programName + ": "); } if (shortProgramDoc.length() > 0) { buf.append(shortProgramDoc + "\n"); } else { buf.append("usage synopsis...\n"); } SortedSet<String> smallRequired = new TreeSet<String>(); SortedSet<String> smallNotRequired = new TreeSet<String>(); SortedSet<String> bigRequired = new TreeSet<String>(); SortedSet<String> bigNotRequired = new TreeSet<String>(); for (String f : docs.keySet()) { boolean req = requireFlag.contains(f); boolean sh = f.length() == 1 && !requireValue.contains(f); if (req && sh) { smallRequired.add(f); } else if (req && !sh) { bigRequired.add(f); } else if (!req && sh) { smallNotRequired.add(f); } else if (!req && !sh) { bigNotRequired.add(f); } } if (programName.length() > 0) { buf.append(programName + " "); } for (String f : smallRequired) { buf.append("-" + f + " "); } if (smallNotRequired.size() > 0) { buf.append(" [ "); for (String f : smallNotRequired) { buf.append("-" + f + " "); } buf.append("] "); } for (String f : bigRequired) { if (requireValue.contains(f)) { buf.append("--" + f + "=..." + " "); } else { buf.append("--" + f + "[=...]" + " "); } } if (bigNotRequired.size() > 0) { buf.append(" [ "); for (String f : bigNotRequired) { if (requireValue.contains(f)) { buf.append("--" + f + "=..." + " "); } else { buf.append("--" + f + " "); } } buf.append("] "); } for (int i = 0; i < positionalDocs.size(); i++) { if (i == requiredPositionArgs) { buf.append(" [ "); } buf.append(positionalDocs.get(i).get(0) + " "); if (i == requiredPositionArgs) { buf.append(" ] "); } } return buf.toString(); }
From source file:com.atlassian.jira.user.util.UserUtilImpl.java
public SortedSet<String> getGroupNamesForUser(final String userName) { notNull("userName", userName); final SortedSet<String> setOfGroups = new TreeSet<String>(); Iterable<String> groups = getGroupNamesForUserFromCrowd(userName); for (String groupName : groups) { setOfGroups.add(groupName); }//from w ww. ja v a 2 s .c om return Collections.unmodifiableSortedSet(setOfGroups); }
From source file:com.revetkn.ios.analyzer.ArtworkAnalyzer.java
/** Modifies the passed-in {@code applicationArtwork} instance to include image reference data. */ protected void detectImageReferences(File projectRootDirectory, final ApplicationArtwork applicationArtwork, final ArtworkExtractionProgressCallback progressCallback) throws Exception { final Map<File, String> contentsOfReferencingFiles = extractContentsOfReferencingFiles( projectRootDirectory);/*from ww w .j a v a2s .c o m*/ final SortedSet<File> unreferencedImageFiles = synchronizedSortedSet(new TreeSet<File>()); final SortedSet<File> onlyProjectFileReferencedImageFiles = synchronizedSortedSet(new TreeSet<File>()); final SortedMap<File, SortedSet<File>> allImageFilesAndReferencingFiles = synchronizedSortedMap( new TreeMap<File, SortedSet<File>>()); final AtomicInteger imageFilesProcessed = new AtomicInteger(0); Set<Callable<Object>> imageReferenceProcessingTasks = new HashSet<Callable<Object>>(); for (final File imageFile : applicationArtwork.getAllImageFiles()) { imageReferenceProcessingTasks.add(new Callable<Object>() { @Override public Object call() throws Exception { String imageFilename = imageFile.getName(); SortedSet<File> filesWhereImageIsReferenced = new TreeSet<File>(); Set<String> imageFilenameVariants = imageFilenameVariants(imageFilename); for (Entry<File, String> entry : contentsOfReferencingFiles.entrySet()) { String fileContents = entry.getValue(); for (String imageFilenameVariant : imageFilenameVariants) { // Quoted references, e.g. "aboutBackground" if (fileContents.indexOf(format("\"%s\"", imageFilenameVariant)) != -1) filesWhereImageIsReferenced.add(entry.getKey()); // Nib files, e.g. <string key="NSResourceName">aboutBackground~ipad.png</string> else if (fileContents.indexOf(format(">%s<", imageFilenameVariant)) != -1) filesWhereImageIsReferenced.add(entry.getKey()); } } if (filesWhereImageIsReferenced.size() == 1 && "project.pbxproj" .equals(filesWhereImageIsReferenced.first().getName().toLowerCase())) onlyProjectFileReferencedImageFiles.add(imageFile); if (filesWhereImageIsReferenced.size() == 0) { unreferencedImageFiles.add(imageFile); } else { allImageFilesAndReferencingFiles.put(imageFile, filesWhereImageIsReferenced); } progressCallback.onProcessedImageReferences(imageFile, filesWhereImageIsReferenced, imageFilesProcessed.incrementAndGet(), applicationArtwork.getAllImageFiles().size()); return null; } }); } for (Future<Object> future : getExecutorService().invokeAll(imageReferenceProcessingTasks)) future.get(); applicationArtwork.setAllImageFilesAndReferencingFiles(allImageFilesAndReferencingFiles); applicationArtwork.setUnreferencedImageFiles(unreferencedImageFiles); applicationArtwork.setOnlyProjectFileReferencedImageFiles(onlyProjectFileReferencedImageFiles); }