Java 类java.util.SortedSet 实例源码
项目:ultrasonic
文件:FileUtil.java
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;
}
项目:hashsdn-controller
文件:FileStorageAdapterTest.java
@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<>();
}
});
}
}
项目:OpenJSharp
文件:SourceWriter.java
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);
}
项目:openjdk-jdk10
文件:InclusiveNamespaces.java
/**
* 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;
}
项目:hashsdn-controller
文件:XmlFileStorageAdapter.java
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();
}
};
}
项目:jdk8u-jdk
文件:EmptyNavigableSet.java
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);
}
项目:lams
文件:MonitoringService.java
@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;
}
项目:launcher-backend
文件:KubernetesClientHelper.java
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;
}
项目:openjdk-jdk10
文件:TreeSubSetTest.java
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());
}
项目:lams
文件:AuthoringAction.java
/**
* 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;
}
项目:Visitor
文件:InternalUtil.java
/**
* 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);
}
项目:crnk-framework
文件:RuntimeClassLoaderFactory.java
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;
}
项目:JavaGraph
文件:RuleModel.java
/**
* 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;
}
项目:googles-monorepo-demo
文件:ImmutableSortedSetTest.java
private static void assertNotEqualLenient(
TreeSet<?> unexpected, SortedSet<?> actual) {
try {
assertThat(actual).isNotEqualTo(unexpected);
} catch (ClassCastException accepted) {
}
}
项目:datarouter
文件:SetTool.java
@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());
}
项目:nifi-registry
文件:BucketFlowResource.java
@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();
}
项目:athena
文件:ComponentNameCompleter.java
@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);
}
项目:JavaGraph
文件:RuleTree.java
/**
* 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);
}
项目:s-store
文件:AbstractMapBasedMultimap.java
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);
}
}
项目:scott-eu
文件:ServiceProviderCatalogSingleton.java
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);
}
}
}
项目:javaide
文件:AbstractResourceRepository.java
/**
* 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;
}
项目:incubator-netbeans
文件:TrieDictionaryTest.java
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é"));
}
项目:googles-monorepo-demo
文件:ImmutableSortedSet.java
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);
}
}
项目:googles-monorepo-demo
文件:IterablesTest.java
public void testGetLast_emptySortedSet() {
SortedSet<String> sortedSet = ImmutableSortedSet.of();
try {
Iterables.getLast(sortedSet);
fail();
} catch (NoSuchElementException e) {}
}
项目:athena
文件:OchSignalTest.java
@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));
}
项目:googles-monorepo-demo
文件:ImmutableSortedSetTest.java
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());
}
项目:lams
文件:LearningAction.java
/**
* 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;
}
项目:flume-release-1.7.0
文件:Log.java
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);
}
}
}
}
项目:lams
文件:AuthoringAction.java
/**
* 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;
}
项目:lams
文件:AuthoringAction.java
/**
* 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);
}
项目:winter
文件:OtherOperations.java
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;
}
项目:n4js
文件:SpecInfo.java
/**
* 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;
}
项目:guava-mock
文件:ImmutableSortedSetTest.java
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());
}
项目:openjdk-jdk10
文件:ClassTree.java
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();
}
}
项目:lams
文件:LearningAction.java
/**
* 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;
}
项目:guava-mock
文件:SetGenerators.java
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());
}
项目:lams
文件:AuthoringTaskListConditionAction.java
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);
}
项目:googles-monorepo-demo
文件:DerivedCollectionGenerators.java
/**
* 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();
}
}
项目:lams
文件:XStream.java
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);
}
项目:googles-monorepo-demo
文件:DerivedCollectionGenerators.java
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);
}
}