Java Code Examples for java.util.SortedSet

The following are top voted examples for showing how to use java.util.SortedSet. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ultrasonic   File: FileUtil.java   View source code 6 votes vote down vote up
public static SortedSet<File> listMediaFiles(File dir)
{
	SortedSet<File> files = listFiles(dir);
	Iterator<File> iterator = files.iterator();

	while (iterator.hasNext())
	{
		File file = iterator.next();

		if (!file.isDirectory() && !isMediaFile(file))
		{
			iterator.remove();
		}
	}

	return files;
}
 
Example 2
Project: hashsdn-controller   File: FileStorageAdapterTest.java   View source code 6 votes vote down vote up
@Test(expected = NullPointerException.class)
public void testNoProperties2() throws Exception {
    try (XmlFileStorageAdapter storage = new XmlFileStorageAdapter()) {
        storage.persistConfig(new ConfigSnapshotHolder() {
            @Override
            public String getConfigSnapshot() {
                return mock(String.class);
            }

            @Override
            public SortedSet<String> getCapabilities() {
                return new TreeSet<>();
            }
        });
    }
}
 
Example 3
Project: OpenJSharp   File: SourceWriter.java   View source code 6 votes vote down vote up
private void setLineMap(Code_attribute attr) {
    SortedMap<Integer, SortedSet<Integer>> map =
            new TreeMap<Integer, SortedSet<Integer>>();
    SortedSet<Integer> allLines = new TreeSet<Integer>();
    for (Attribute a: attr.attributes) {
        if (a instanceof LineNumberTable_attribute) {
            LineNumberTable_attribute t = (LineNumberTable_attribute) a;
            for (LineNumberTable_attribute.Entry e: t.line_number_table) {
                int start_pc = e.start_pc;
                int line = e.line_number;
                SortedSet<Integer> pcLines = map.get(start_pc);
                if (pcLines == null) {
                    pcLines = new TreeSet<Integer>();
                    map.put(start_pc, pcLines);
                }
                pcLines.add(line);
                allLines.add(line);
            }
        }
    }
    lineMap = map;
    lineList = new ArrayList<Integer>(allLines);
}
 
Example 4
Project: openjdk-jdk10   File: InclusiveNamespaces.java   View source code 6 votes vote down vote up
/**
 * Decodes the <code>inclusiveNamespaces</code> String and returns all
 * selected namespace prefixes as a Set. The <code>#default</code>
 * namespace token is represented as an empty namespace prefix
 * (<code>"xmlns"</code>).
 * <BR/>
 * The String <code>inclusiveNamespaces=" xenc    ds #default"</code>
 * is returned as a Set containing the following Strings:
 * <UL>
 * <LI><code>xmlns</code></LI>
 * <LI><code>xenc</code></LI>
 * <LI><code>ds</code></LI>
 * </UL>
 *
 * @param inclusiveNamespaces
 * @return A set to string
 */
public static SortedSet<String> prefixStr2Set(String inclusiveNamespaces) {
    SortedSet<String> prefixes = new TreeSet<String>();

    if ((inclusiveNamespaces == null) || (inclusiveNamespaces.length() == 0)) {
        return prefixes;
    }

    String[] tokens = inclusiveNamespaces.split("\\s");
    for (String prefix : tokens) {
        if (prefix.equals("#default")) {
            prefixes.add("xmlns");
        } else {
            prefixes.add(prefix);
        }
    }

    return prefixes;
}
 
Example 5
Project: hashsdn-controller   File: XmlFileStorageAdapter.java   View source code 6 votes vote down vote up
public ConfigSnapshotHolder toConfigSnapshot(final ConfigSnapshot configSnapshot) {
    return new ConfigSnapshotHolder() {
        @Override
        public String getConfigSnapshot() {
            return configSnapshot.getConfigSnapshot();
        }

        @Override
        public SortedSet<String> getCapabilities() {
            return configSnapshot.getCapabilities();
        }

        @Override
        public String toString() {
            return configSnapshot.toString();
        }
    };
}
 
Example 6
Project: jdk8u-jdk   File: EmptyNavigableSet.java   View source code 6 votes vote down vote up
public static final boolean isDescending(SortedSet<?> set) {
    if (null == set.comparator()) {
        // natural order
        return false;
    }

    if (Collections.reverseOrder() == set.comparator()) {
        // reverse natural order.
        return true;
    }

    if (set.comparator().equals(Collections.reverseOrder(Collections.reverseOrder(set.comparator())))) {
        // it's a Collections.reverseOrder(Comparator).
        return true;
    }

    throw new IllegalStateException("can't determine ordering for " + set);
}
 
Example 7
Project: lams   File: MonitoringService.java   View source code 6 votes vote down vote up
@Override
   public SortedSet<Group> getGroupsNotAssignedToBranch(Long branchingActivityID) throws LessonServiceException {

BranchingActivity branchingActivity = (BranchingActivity) getActivityById(branchingActivityID);
if (branchingActivity == null) {
    String error = "getGroupsNotAssignedToBranch: Branching Activity missing missing. ActivityID was "
	    + branchingActivityID;
    MonitoringService.log.error(error);
    throw new MonitoringServiceException(error);
}

TreeSet<Group> unassignedGroups = new TreeSet<Group>();

Grouping grouping = branchingActivity.getGrouping();
Iterator groupIterator = grouping.getGroups().iterator();
while (groupIterator.hasNext()) {
    Group group = (Group) groupIterator.next();
    if ((group.getBranchActivities() == null) || (group.getBranchActivities().size() == 0)) {
	unassignedGroups.add(group);
    }
}

return unassignedGroups;

   }
 
Example 8
Project: launcher-backend   File: KubernetesClientHelper.java   View source code 6 votes vote down vote up
public List<SpaceDTO> loadSpaces(String namespace) {
    List<SpaceDTO> answer = new ArrayList<>();
    if (namespace != null) {
        try {
            Spaces spacesValue = Spaces.load(kubernetesClient, namespace);
            if (spacesValue != null) {
                SortedSet<Space> spaces = spacesValue.getSpaceSet();
                for (Space space : spaces) {
                    answer.add(new SpaceDTO(space.getName(), space.getName()));
                }
            }
        } catch (Exception e) {
            LOG.warn("Failed to load spaces: " + e, e);
        }
    }
    return answer;
}
 
Example 9
Project: openjdk-jdk10   File: TreeSubSetTest.java   View source code 6 votes vote down vote up
public void testSubSetContents2() {
    NavigableSet set = set5();
    SortedSet sm = set.subSet(two, three);
    assertEquals(1, sm.size());
    assertEquals(two, sm.first());
    assertEquals(two, sm.last());
    assertFalse(sm.contains(one));
    assertTrue(sm.contains(two));
    assertFalse(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(two, k);
    assertFalse(i.hasNext());
    Iterator j = sm.iterator();
    j.next();
    j.remove();
    assertFalse(set.contains(two));
    assertEquals(4, set.size());
    assertEquals(0, sm.size());
    assertTrue(sm.isEmpty());
    assertFalse(sm.remove(three));
    assertEquals(4, set.size());
}
 
Example 10
Project: lams   File: AuthoringAction.java   View source code 6 votes vote down vote up
/**
    * Updates SessionMap using Notebook content.
    *
    * @param notebook
    * @param mode
    */
   private SessionMap<String, Object> createSessionMap(Notebook notebook, ToolAccessMode mode, String contentFolderID,
    Long toolContentID) {

SessionMap<String, Object> map = new SessionMap<String, Object>();

map.put(AuthoringAction.KEY_MODE, mode);
map.put(AuthoringAction.KEY_CONTENT_FOLDER_ID, contentFolderID);
map.put(AuthoringAction.KEY_TOOL_CONTENT_ID, toolContentID);
map.put(NotebookConstants.ATTR_DELETED_CONDITION_LIST, new ArrayList<NotebookCondition>());

SortedSet<NotebookCondition> set = new TreeSet<NotebookCondition>(new TextSearchConditionComparator());

if (notebook.getConditions() != null) {
    set.addAll(notebook.getConditions());
}
map.put(NotebookConstants.ATTR_CONDITION_SET, set);
return map;
   }
 
Example 11
Project: Visitor   File: InternalUtil.java   View source code 6 votes vote down vote up
/**
 * auto Adaptation List, NavigableSet, SortedSet, Set and Collection.
 * 
 * @param <T>
 *            the element type
 * @param collection
 *            the target collection
 * @return a unmodifiable collection
 */
public static <T> Collection<T> unmodifiable(Collection<T> collection) {

	if (collection instanceof List) {
		return Collections.unmodifiableList((List<? extends T>) collection);
	}
	/*
	 * else if (collection instanceof NavigableSet) {
	 * if(JDKVersion.isJdK18()){ //jdk1.8 return
	 * Collections.unmodifiableNavigableSet((NavigableSet<T>) collection); }
	 * }
	 */
	else if (collection instanceof SortedSet) {
		return Collections.unmodifiableSortedSet((SortedSet<T>) collection);
	} else if (collection instanceof Set) {
		return Collections.unmodifiableSet((Set<? extends T>) collection);
	}
	return Collections.unmodifiableCollection(collection);
}
 
Example 12
Project: crnk-framework   File: RuntimeClassLoaderFactory.java   View source code 5 votes vote down vote up
public Set<File> getProjectLibraries() {
	Set<File> classpath = new HashSet<>();

	SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");

	if (sourceSets != null) {
		SortedSet<String> availableSourceSetNames = sourceSets.getNames();
		for (String sourceSetName : Arrays.asList("main", "test", "integrationTest")) {
			if (availableSourceSetNames.contains(sourceSetName)) {
				SourceSet sourceSet = sourceSets.getByName(sourceSetName);
				classpath.add(sourceSet.getOutput().getClassesDir());
			}
		}
	}

	// add  dependencies from configured gradle configuration to url (usually test or integrationTest)
	TSGeneratorConfig generatorConfiguration = project.getExtensions().getByType(TSGeneratorConfig.class);
	String configurationName = generatorConfiguration.getRuntime().getConfiguration();

	ConfigurationContainer configurations = project.getConfigurations();
	Configuration runtimeConfiguration = configurations.findByName(configurationName + "Runtime");
	if (runtimeConfiguration == null) {
		runtimeConfiguration = configurations.getByName(configurationName);
	}
	classpath.addAll(runtimeConfiguration.getFiles());

	for (File file : classpath) {
		LOGGER.debug("classpath entry: {}", file);
	}

	return classpath;
}
 
Example 13
Project: JavaGraph   File: RuleModel.java   View source code 5 votes vote down vote up
/**
 * Returns the set of nodes in this cell. Only call after
 * the cell has been completely fixed.
 */
public SortedSet<RuleNode> getNodes() {
    setFixed();
    if (this.nodes == null) {
        this.nodes = computeNodes();
    }
    return this.nodes;
}
 
Example 14
Project: googles-monorepo-demo   File: ImmutableSortedSetTest.java   View source code 5 votes vote down vote up
private static void assertNotEqualLenient(
    TreeSet<?> unexpected, SortedSet<?> actual) {
  try {
    assertThat(actual).isNotEqualTo(unexpected);
  } catch (ClassCastException accepted) {
  }
}
 
Example 15
Project: datarouter   File: SetTool.java   View source code 5 votes vote down vote up
@Test
public void testNullSafeAddAllWithEmptySet(){
	SortedSet<String> set = new TreeSet<>();
	set.add("b");
	Set<String> toAdd = new HashSet<>();
	toAdd.add("a");
	set = nullSafeSortedAddAll(set, toAdd);
	set.add("c");
	Assert.assertEquals(new String[]{"a", "b", "c"}, set.toArray());
}
 
Example 16
Project: nifi-registry   File: BucketFlowResource.java   View source code 5 votes vote down vote up
@GET
@Path("{flowId}/versions")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Gets summary information for all versions of a flow. Versions are ordered newest->oldest.",
        response = VersionedFlowSnapshotMetadata.class,
        responseContainer = "List"
)
@ApiResponses({
        @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
        @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
        @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getFlowVersions(
        @PathParam("bucketId")
        @ApiParam("The bucket identifier")
            final String bucketId,
        @PathParam("flowId")
        @ApiParam("The flow identifier")
            final String flowId) {

    authorizeBucketAccess(RequestAction.READ, bucketId);

    final SortedSet<VersionedFlowSnapshotMetadata> snapshots = registryService.getFlowSnapshots(bucketId, flowId);
    if (snapshots != null ) {
        linkService.populateSnapshotLinks(snapshots);
    }

    return Response.status(Response.Status.OK).entity(snapshots).build();
}
 
Example 17
Project: athena   File: ComponentNameCompleter.java   View source code 5 votes vote down vote up
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    // Fetch our service and feed it's offerings to the string completer
    ComponentConfigService service = AbstractShellCommand.get(ComponentConfigService.class);
    SortedSet<String> strings = delegate.getStrings();
    service.getComponentNames().forEach(strings::add);

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(buffer, cursor, candidates);
}
 
Example 18
Project: JavaGraph   File: RuleTree.java   View source code 5 votes vote down vote up
/**
 * Refreshes the selection in the tree, based on the current state of the
 * Simulator.
 */
private void refresh(GraphState state) {
    SortedSet<GraphTransitionKey> matches = new TreeSet<>(GraphTransitionKey.COMPARATOR);
    if (state != null) {
        for (GraphTransition trans : state.getTransitions(Claz.ANY)) {
            matches.add(trans.getKey());
        }
        matches.addAll(state.getMatches());
    }
    refreshMatches(state, matches);
    setEnabled(getGrammar() != null);
}
 
Example 19
Project: s-store   File: AbstractMapBasedMultimap.java   View source code 5 votes vote down vote up
Collection<V> unmodifiableCollectionSubclass(Collection<V> collection) {
  // We don't deal with NavigableSet here yet for GWT reasons -- instead,
  // non-GWT TreeMultimap explicitly overrides this and uses NavigableSet.
  if (collection instanceof SortedSet) {
    return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
  } else if (collection instanceof Set) {
    return Collections.unmodifiableSet((Set<V>) collection);
  } else if (collection instanceof List) {
    return Collections.unmodifiableList((List<V>) collection);
  } else {
    return Collections.unmodifiableCollection(collection);
  }
}
 
Example 20
Project: scott-eu   File: ServiceProviderCatalogSingleton.java   View source code 5 votes vote down vote up
public static void deregisterServiceProvider(final String serviceProviderId)
{
    synchronized(serviceProviders)
    {
        final ServiceProvider deregisteredServiceProvider =
            serviceProviders.remove(serviceProviderIdentifier(serviceProviderId));

        if (deregisteredServiceProvider != null)
        {
            final SortedSet<URI> remainingDomains = new TreeSet<URI>();

            for (final ServiceProvider remainingServiceProvider : serviceProviders.values())
            {
                remainingDomains.addAll(getServiceProviderDomains(remainingServiceProvider));
            }

            final SortedSet<URI> removedServiceProviderDomains = getServiceProviderDomains(deregisteredServiceProvider);

            removedServiceProviderDomains.removeAll(remainingDomains);
            serviceProviderCatalog.removeDomains(removedServiceProviderDomains);
            serviceProviderCatalog.removeServiceProvider(deregisteredServiceProvider);
        }
        else
        {
            throw new WebApplicationException(Status.NOT_FOUND);
        }
    }
}
 
Example 21
Project: javaide   File: AbstractResourceRepository.java   View source code 5 votes vote down vote up
/**
 * Returns the sorted list of languages used in the resources.
 */
@NonNull
public SortedSet<String> getLanguages() {
    SortedSet<String> set = new TreeSet<String>();

    // As an optimization we could just look for values since that's typically where
    // the languages are defined -- not on layouts, menus, etc -- especially if there
    // are no translations for it
    Set<String> qualifiers = Sets.newHashSet();

    synchronized (ITEM_MAP_LOCK) {
        for (ListMultimap<String, ResourceItem> map : getMap().values()) {
            for (ResourceItem item : map.values()) {
                qualifiers.add(item.getQualifiers());
            }
        }
    }

    Splitter splitter = Splitter.on('-');
    for (String s : qualifiers) {
        for (String qualifier : splitter.split(s)) {
            if (qualifier.length() == 2 && Character.isLetter(qualifier.charAt(0))
                    && Character.isLetter(qualifier.charAt(1))) {
                set.add(qualifier);
            }
        }
    }

    return set;
}
 
Example 22
Project: incubator-netbeans   File: TrieDictionaryTest.java   View source code 5 votes vote down vote up
public void test150642() throws Exception {
    SortedSet<String> data = new TreeSet<String>();

    data.add("abc");
    data.add("aéc");

    Dictionary d = constructTrie(data);

    assertEquals(ValidityType.VALID, d.validateWord("abc"));
    assertEquals(ValidityType.VALID, d.validateWord("aéc"));

    assertEquals(ValidityType.PREFIX_OF_VALID, d.validateWord("a"));
    assertEquals(ValidityType.PREFIX_OF_VALID, d.validateWord("ab"));
    assertEquals(ValidityType.PREFIX_OF_VALID, d.validateWord("aé"));
}
 
Example 23
Project: googles-monorepo-demo   File: ImmutableSortedSet.java   View source code 5 votes vote down vote up
private static <E> ImmutableSortedSet<E> ofInternal(
    Comparator<? super E> comparator, E... elements) {
  checkNotNull(elements);
  switch (elements.length) {
    case 0:
      return emptySet(comparator);
    default:
      SortedSet<E> delegate = new TreeSet<E>(comparator);
      for (E element : elements) {
        checkNotNull(element);
        delegate.add(element);
      }
      return new RegularImmutableSortedSet<E>(delegate, false);
  }
}
 
Example 24
Project: googles-monorepo-demo   File: IterablesTest.java   View source code 5 votes vote down vote up
public void testGetLast_emptySortedSet() {
  SortedSet<String> sortedSet = ImmutableSortedSet.of();
  try {
    Iterables.getLast(sortedSet);
    fail();
  } catch (NoSuchElementException e) {}
}
 
Example 25
Project: athena   File: OchSignalTest.java   View source code 5 votes vote down vote up
@Test
public void testToFixedgrid50plus1() {
    SortedSet<OchSignal> input = newOchSignalTreeSet();
    // Note: 8 = 50Ghz / 6.25Ghz
    input.addAll(ImmutableList.of(
                newFlexGridSlot(8 - 3), newFlexGridSlot(8 - 1),
                newFlexGridSlot(8 + 1), newFlexGridSlot(8 + 3)));

    OchSignal expected = newDwdmSlot(CHL_50GHZ, 1);
    assertEquals(expected, OchSignal.toFixedGrid(Lists.newArrayList(input), CHL_50GHZ));
}
 
Example 26
Project: googles-monorepo-demo   File: ImmutableSortedSetTest.java   View source code 5 votes vote down vote up
public void testExplicit_tailSet() {
  SortedSet<String> set = ImmutableSortedSet.orderedBy(STRING_LENGTH).add(
      "in", "the", "quick", "jumped", "over", "a").build();
  assertTrue(set.tailSet("california") instanceof ImmutableSortedSet);
  assertTrue(set.tailSet("fish") instanceof ImmutableSortedSet);
  assertThat(set.tailSet("fish")).containsExactly("over", "quick", "jumped").inOrder();
  assertThat(
      set.tailSet("a")).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder();
  assertTrue(set.tailSet("california").isEmpty());
}
 
Example 27
Project: lams   File: LearningAction.java   View source code 5 votes vote down vote up
/**
    * List save current resource items.
    *
    * @param request
    * @return
    */
   private SortedSet<ResourceItem> getResourceItemList(SessionMap<String, Object> sessionMap) {
SortedSet<ResourceItem> list = (SortedSet<ResourceItem>) sessionMap
	.get(ResourceConstants.ATTR_RESOURCE_ITEM_LIST);
if (list == null) {
    list = new TreeSet<ResourceItem>(new ResourceItemComparator());
    sessionMap.put(ResourceConstants.ATTR_RESOURCE_ITEM_LIST, list);
}
return list;
   }
 
Example 28
Project: flume-release-1.7.0   File: Log.java   View source code 5 votes vote down vote up
private void removeOldLogs(SortedSet<Integer> fileIDs) {
  Preconditions.checkState(open, "Log is closed");
  // To maintain a single code path for deletes, if backup of checkpoint is
  // enabled or not, we will track the files which can be deleted after the
  // current checkpoint (since the one which just got backed up still needs
  // these files) and delete them only after the next (since the current
  // checkpoint will become the backup at that time,
  // and thus these files are no longer needed).
  for (File fileToDelete : pendingDeletes) {
    LOGGER.info("Removing old file: " + fileToDelete);
    FileUtils.deleteQuietly(fileToDelete);
  }
  pendingDeletes.clear();
  // we will find the smallest fileID currently in use and
  // won't delete any files with an id larger than the min
  int minFileID = fileIDs.first();
  LOGGER.debug("Files currently in use: " + fileIDs);
  for (File logDir : logDirs) {
    List<File> logs = LogUtils.getLogs(logDir);
    // sort oldset to newest
    LogUtils.sort(logs);
    // ensure we always keep two logs per dir
    int size = logs.size() - MIN_NUM_LOGS;
    for (int index = 0; index < size; index++) {
      File logFile = logs.get(index);
      int logFileID = LogUtils.getIDForFile(logFile);
      if (logFileID < minFileID) {
        LogFile.RandomReader reader = idLogFileMap.remove(logFileID);
        if (reader != null) {
          reader.close();
        }
        File metaDataFile = Serialization.getMetaDataFile(logFile);
        pendingDeletes.add(logFile);
        pendingDeletes.add(metaDataFile);
      }
    }
  }
}
 
Example 29
Project: lams   File: AuthoringAction.java   View source code 5 votes vote down vote up
/**
    * List save current taskList items.
    */
   private SortedSet<KalturaItem> getItemList(SessionMap<String, Object> sessionMap) {
SortedSet<KalturaItem> list = (SortedSet<KalturaItem>) sessionMap.get(KalturaConstants.ATTR_ITEM_LIST);
if (list == null) {
    list = new TreeSet<KalturaItem>(new KalturaItemComparator());
    sessionMap.put(KalturaConstants.ATTR_ITEM_LIST, list);
}
return list;
   }
 
Example 30
Project: lams   File: AuthoringAction.java   View source code 5 votes vote down vote up
/**
    * 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);
   }
 
Example 31
Project: winter   File: OtherOperations.java   View source code 5 votes vote down vote up
public <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(
		Map<K, V> map) {
	SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(
			new Comparator<Map.Entry<K, V>>() {
				public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
					int res = e1.getValue().compareTo(e2.getValue());
					return res != 0 ? res : 1;
				}
			});
	sortedEntries.addAll(map.entrySet());
	return sortedEntries;
}
 
Example 32
Project: n4js   File: SpecInfo.java   View source code 5 votes vote down vote up
/**
 * Returns all tests for inherited members.
 *
 * @return maybe empty set, never null
 */
public Map<TMember, SortedSet<SpecTestInfo>> getTestsForInheritedMembers() {
	HashMap<TMember, SortedSet<SpecTestInfo>> m = new HashMap<>();

	for (Entry<TMember, SortedSet<SpecTestInfo>> e : relatedMemberTests.entrySet()) {
		// do not add tests for polyfilled members, they are treated as
		// "normal" method tests, cf. IDE-2160
		TMember member = e.getKey();
		if (member.getContainingType() != specElementRef.identifiableElement && !member.isPolyfilled()) {
			m.put(member, e.getValue());
		}
	}
	return m;
}
 
Example 33
Project: guava-mock   File: ImmutableSortedSetTest.java   View source code 5 votes vote down vote up
public void testExplicit_tailSet() {
  SortedSet<String> set = ImmutableSortedSet.orderedBy(STRING_LENGTH).add(
      "in", "the", "quick", "jumped", "over", "a").build();
  assertTrue(set.tailSet("california") instanceof ImmutableSortedSet);
  assertTrue(set.tailSet("fish") instanceof ImmutableSortedSet);
  assertThat(set.tailSet("fish")).containsExactly("over", "quick", "jumped").inOrder();
  assertThat(
      set.tailSet("a")).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder();
  assertTrue(set.tailSet("california").isEmpty());
}
 
Example 34
Project: openjdk-jdk10   File: ClassTree.java   View source code 5 votes vote down vote up
private SortedSet<TypeElement> directSubClasses0(TypeElement typeElement, boolean isEnum) {
    if (isEnum) {
        return get(subEnums, typeElement);
    } else if (utils.isAnnotationType(typeElement)) {
        return get(subAnnotationTypes, typeElement);
    } else if (utils.isInterface(typeElement)) {
        return get(subInterfaces, typeElement);
    } else if (utils.isClass(typeElement)) {
        return get(subClasses, typeElement);
    } else {
        return Collections.emptySortedSet();
    }
}
 
Example 35
Project: lams   File: LearningAction.java   View source code 5 votes vote down vote up
/**
    * List save current daco questions.
    *
    * @param request
    * @return
    */
   protected SortedSet<DacoQuestion> getDacoQuestionList(SessionMap sessionMap) {
SortedSet<DacoQuestion> list = (SortedSet<DacoQuestion>) sessionMap.get(DacoConstants.ATTR_QUESTION_LIST);
if (list == null) {
    list = new TreeSet<DacoQuestion>(new DacoQuestionComparator());
    sessionMap.put(DacoConstants.ATTR_QUESTION_LIST, list);
}
return list;
   }
 
Example 36
Project: guava-mock   File: SetGenerators.java   View source code 5 votes vote down vote up
protected final ContiguousSet<Integer> checkedCreate(SortedSet<Integer> elementsSet) {
  List<Integer> elements = newArrayList(elementsSet);
  /*
   * A ContiguousSet can't have holes. If a test demands a hole, it should be changed so that it
   * doesn't need one, or it should be suppressed for ContiguousSet.
   */
  for (int i = 0; i < elements.size() - 1; i++) {
    assertEquals(elements.get(i) + 1, (int) elements.get(i + 1));
  }
  Range<Integer> range =
      (elements.isEmpty()) ? Range.closedOpen(0, 0) : Range.encloseAll(elements);
  return ContiguousSet.create(range, DiscreteDomain.integers());
}
 
Example 37
Project: lams   File: AuthoringTaskListConditionAction.java   View source code 5 votes vote down vote up
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// 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);
    // get current and the target item, and switch their sequnece
    TaskListCondition condition = rList.get(sequenceId);
    TaskListCondition repCondition;
    if (up) {
	repCondition = rList.get(--sequenceId);
    } else {
	repCondition = rList.get(++sequenceId);
    }
    int upSeqId = repCondition.getSequenceId();
    repCondition.setSequenceId(condition.getSequenceId());
    condition.setSequenceId(upSeqId);

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

request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(TaskListConstants.SUCCESS);
   }
 
Example 38
Project: googles-monorepo-demo   File: DerivedCollectionGenerators.java   View source code 5 votes vote down vote up
/**
 * Calls the smallest subSet overload that filters out the extreme values.
 */
SortedSet<E> createSubSet(SortedSet<E> set, E firstExclusive, E lastExclusive) {
  if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
    return set.headSet(lastExclusive);
  } else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
    return set.tailSet(firstInclusive);
  } else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
    return set.subSet(firstInclusive, lastExclusive);
  } else {
    throw new IllegalArgumentException();
  }
}
 
Example 39
Project: lams   File: XStream.java   View source code 5 votes vote down vote up
protected void setupDefaultImplementations() {
    if (defaultImplementationsMapper == null) {
        return;
    }
    addDefaultImplementation(HashMap.class, Map.class);
    addDefaultImplementation(ArrayList.class, List.class);
    addDefaultImplementation(HashSet.class, Set.class);
    addDefaultImplementation(TreeSet.class, SortedSet.class);
    addDefaultImplementation(GregorianCalendar.class, Calendar.class);
}
 
Example 40
Project: googles-monorepo-demo   File: DerivedCollectionGenerators.java   View source code 5 votes vote down vote up
static <K, V> TestSetGenerator<K> keySetGenerator(
    OneSizeTestContainerGenerator<Map<K, V>, Map.Entry<K, V>> mapGenerator) {
  TestContainerGenerator<Map<K, V>, Entry<K, V>> generator = mapGenerator.getInnerGenerator();
  if (generator instanceof TestSortedMapGenerator
      && ((TestSortedMapGenerator<K, V>) generator).create().keySet() instanceof SortedSet) {
    return new MapSortedKeySetGenerator<K, V>(mapGenerator);
  } else {
    return new MapKeySetGenerator<K, V>(mapGenerator);
  }
}