本文整理汇总了Java中java.util.SortedSet.remove方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSet.remove方法的具体用法?Java SortedSet.remove怎么用?Java SortedSet.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SortedSet
的用法示例。
在下文中一共展示了SortedSet.remove方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBiggestObjectsByRetainedSize
import java.util.SortedSet; //导入方法依赖的package包/类
long[] getBiggestObjectsByRetainedSize(int number) {
SortedSet bigObjects = new TreeSet();
long[] bigIds = new long[number];
long min = 0;
for (long index=0;index<fileSize;index+=ENTRY_SIZE) {
long id = getID(index);
if (id != 0) {
long retainedSize = createEntry(index).getRetainedSize();
if (bigObjects.size()<number) {
bigObjects.add(new RetainedSizeEntry(id,retainedSize));
min = ((RetainedSizeEntry)bigObjects.last()).retainedSize;
} else if (retainedSize>min) {
bigObjects.remove(bigObjects.last());
bigObjects.add(new RetainedSizeEntry(id,retainedSize));
min = ((RetainedSizeEntry)bigObjects.last()).retainedSize;
}
}
}
int i = 0;
Iterator it = bigObjects.iterator();
while(it.hasNext()) {
bigIds[i++]=((RetainedSizeEntry)it.next()).instanceId;
}
return bigIds;
}
示例2: testAllVersionsTested
import java.util.SortedSet; //导入方法依赖的package包/类
public void testAllVersionsTested() throws Exception {
SortedSet<String> expectedVersions = new TreeSet<>();
for (Version v : VersionUtils.allReleasedVersions()) {
if (VersionUtils.isSnapshot(v)) continue; // snapshots are unreleased, so there is no backcompat yet
if (v.isRelease() == false) continue; // no guarantees for prereleases
if (v.before(Version.CURRENT.minimumIndexCompatibilityVersion())) continue; // we can only support one major version backward
if (v.equals(Version.CURRENT)) continue; // the current version is always compatible with itself
expectedVersions.add("index-" + v.toString() + ".zip");
}
for (String index : indexes) {
if (expectedVersions.remove(index) == false) {
logger.warn("Old indexes tests contain extra index: {}", index);
}
}
if (expectedVersions.isEmpty() == false) {
StringBuilder msg = new StringBuilder("Old index tests are missing indexes:");
for (String expected : expectedVersions) {
msg.append("\n" + expected);
}
fail(msg.toString());
}
}
示例3: movedTo
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public synchronized void movedTo(final Robot robot, final ITreeNode source, final ITreeNode destination) {
// Remove the robot from the source
if (source != null) {
final SortedSet<Robot> robotsAtSource = this.mNodeToRobots.get(source);
if (robotsAtSource != null) {
robotsAtSource.remove(robot);
}
}
// Add the robot to the destination
SortedSet<Robot> robotsAtDestination = this.mNodeToRobots.get(destination);
if (robotsAtDestination == null) {
robotsAtDestination = new TreeSet<>();
this.mNodeToRobots.put(destination, robotsAtDestination);
}
robotsAtDestination.add(robot);
}
示例4: getConfusionMatrix
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* @param title matrix title
* @return confusion matrix as a list of list of String
*/
public List<List<String>> getConfusionMatrix(String title) {
List<List<String>> matrix = new ArrayList<List<String>>();
List<String> row = new ArrayList<String>();
row.add(" ");
matrix.add(row); // spacer
row = new ArrayList<String>();
row.add(title);
matrix.add(row); // title
SortedSet<String> features = new TreeSet<String>(getFeatureValues());
row = new ArrayList<String>();
row.add("A \\ B");
row.addAll(features);
matrix.add(row); // heading horizontal
for (float[] confusionValues : getConfusionMatrix()) {
row = new ArrayList<String>();
row.add(features.first()); // heading vertical
features.remove(features.first());
for (float confusionValue : confusionValues) {
row.add(String.valueOf((int) confusionValue));
}
matrix.add(row); // confusion values
}
return matrix;
}
示例5: build
import java.util.SortedSet; //导入方法依赖的package包/类
public List<CloudApplicationExtended> build(Set<String> mtaModulesInArchive, Set<String> allMtaModules, Set<String> deployedModules)
throws SLException {
List<CloudApplicationExtended> apps = new ArrayList<>();
SortedSet<String> unresolvedMtaModules = new TreeSet<>(allMtaModules);
initializeModulesDependecyTypes(deploymentDescriptor);
for (Module module : handler.getSortedModules(deploymentDescriptor, SupportedParameters.DEPENDENCY_TYPE, DEPENDECY_TYPE_HARD)) {
if (!mtaModulesInArchive.contains(module.getName()) || module.getType() == null) {
if (deployedModules.contains(module.getName())){
printMTAModuleNotFoundWarning(module.getName());
}
continue;
}
if (allMtaModules.contains(module.getName())) {
ListUtil.addNonNull(apps, getApplication(module));
unresolvedMtaModules.remove(module.getName());
} else {
throw new ContentException(Messages.ARCHIVE_MODULE_NOT_INTENDED_FOR_DEPLOYMENT, module.getName());
}
}
unresolvedMtaModules.removeAll(deployedModules);
if (!unresolvedMtaModules.isEmpty()) {
throw new ContentException(Messages.UNRESOLVED_MTA_MODULES, unresolvedMtaModules);
}
return apps;
}
示例6: searchNeighbors
import java.util.SortedSet; //导入方法依赖的package包/类
private Map<String, SortedSet<IndexDistance>> searchNeighbors(ExampleSet exampleSet, Example example, int exampleIndex,
Attribute label, int numberOfNeighbors) {
Map<String, SortedSet<IndexDistance>> neighborSets = new HashMap<>();
if (label.isNominal()) {
for (String value : label.getMapping().getValues()) {
neighborSets.put(value, new TreeSet<IndexDistance>());
}
} else {
neighborSets.put("regression", new TreeSet<IndexDistance>());
}
int exampleCounter = 0;
for (Example candidate : exampleSet) {
if (exampleIndex != exampleCounter) {
double distance = calculateDistance(example, candidate);
SortedSet<IndexDistance> currentSet = null;
if (label.isNominal()) {
String classValue = candidate.getValueAsString(label);
currentSet = neighborSets.get(classValue);
} else {
currentSet = neighborSets.get("regression");
}
currentSet.add(new IndexDistance(exampleCounter, distance));
if (currentSet.size() > numberOfNeighbors) {
currentSet.remove(currentSet.last());
}
}
exampleCounter++;
}
return neighborSets;
}
示例7: testRestoreOldSnapshots
import java.util.SortedSet; //导入方法依赖的package包/类
public void testRestoreOldSnapshots() throws Exception {
String repo = "test_repo";
String snapshot = "test_1";
List<String> repoVersions = repoVersions();
assertThat(repoVersions.size(), greaterThan(0));
for (String version : repoVersions) {
createRepo("repo", version, repo);
testOldSnapshot(version, repo, snapshot);
}
SortedSet<String> expectedVersions = new TreeSet<>();
for (Version v : VersionUtils.allReleasedVersions()) {
if (VersionUtils.isSnapshot(v)) continue; // snapshots are unreleased, so there is no backcompat yet
if (v.isRelease() == false) continue; // no guarantees for prereleases
if (v.before(Version.CURRENT.minimumIndexCompatibilityVersion())) continue; // we only support versions N and N-1
if (v.equals(Version.CURRENT)) continue; // the current version is always compatible with itself
expectedVersions.add(v.toString());
}
for (String repoVersion : repoVersions) {
if (expectedVersions.remove(repoVersion) == false) {
logger.warn("Old repositories tests contain extra repo: {}", repoVersion);
}
}
if (expectedVersions.isEmpty() == false) {
StringBuilder msg = new StringBuilder("Old repositories tests are missing versions:");
for (String expected : expectedVersions) {
msg.append("\n" + expected);
}
fail(msg.toString());
}
}
示例8: testAsMapSortedReadsThrough
import java.util.SortedSet; //导入方法依赖的package包/类
public void testAsMapSortedReadsThrough() {
SortedSet<String> strings = new NonNavigableSortedSet();
Collections.addAll(strings, "one", "two", "three");
SortedMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
assertNull(map.comparator());
assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5), map);
assertNull(map.get("four"));
strings.add("four");
assertEquals(
ImmutableSortedMap.of("one", 3, "two", 3, "three", 5, "four", 4),
map);
assertEquals(Integer.valueOf(4), map.get("four"));
SortedMap<String, Integer> headMap = map.headMap("two");
assertEquals(
ImmutableSortedMap.of("four", 4, "one", 3, "three", 5),
headMap);
strings.add("five");
strings.remove("one");
assertEquals(
ImmutableSortedMap.of("five", 4, "four", 4, "three", 5),
headMap);
assertThat(map.entrySet()).containsExactly(
mapEntry("five", 4),
mapEntry("four", 4),
mapEntry("three", 5),
mapEntry("two", 3)).inOrder();
}
示例9: remove
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public synchronized boolean remove(Object o) {
SortedSet<E> newSet = new TreeSet<E>(internalSet);
boolean removed = newSet.remove(o);
internalSet = newSet;
return removed;
}
示例10: beforeCommit
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Pre-commit cleanup.
* <p>
* Ensures that the session transaction listeners are property executed.
*
* The Lucene indexes are then prepared.
*/
@Override
public void beforeCommit(boolean readOnly)
{
if (logger.isDebugEnabled())
{
logger.debug("Before commit " + (readOnly ? "read-only" : "" ) + this);
}
// get the txn ID
TransactionSynchronizationImpl synch = (TransactionSynchronizationImpl)
TransactionSynchronizationManager.getResource(RESOURCE_KEY_TXN_SYNCH);
if (synch == null)
{
throw new AlfrescoRuntimeException("No synchronization bound to thread");
}
logger.trace("Before Prepare - level 0");
// Run the priority 0 (normal) listeners
// These are still considered part of the transaction so are executed here
doBeforeCommit(readOnly);
// Now run the > 0 listeners beforeCommit
Set<Integer> priorities = priorityLookup.keySet();
SortedSet<Integer> sortedPriorities = new ConcurrentSkipListSet<Integer>(FORWARD_INTEGER_ORDER);
sortedPriorities.addAll(priorities);
sortedPriorities.remove(0); // already done level 0 above
if(logger.isDebugEnabled())
{
logger.debug("Before Prepare priorities:" + sortedPriorities);
}
for(Integer priority : sortedPriorities)
{
Set<TransactionListener> listeners = priorityLookup.get(priority);
for(TransactionListener listener : listeners)
{
listener.beforeCommit(readOnly);
}
}
if(logger.isDebugEnabled())
{
logger.debug("Prepared");
}
}
示例11: testMultiTransactions
import java.util.SortedSet; //导入方法依赖的package包/类
@Test
public void testMultiTransactions() throws InterruptedException {
// System.out.println("testMultiTransactions");
CountDownLatch latch = new CountDownLatch(1);
LinkedList LL = new LinkedList();
ConcurrentSkipListMap<Long, ArrayList<Pair>> map = new ConcurrentSkipListMap<>();
ArrayList<Thread> threads = new ArrayList<>(THREADS);
for (int i = 0; i < THREADS; i++) {
threads.add(new Thread(new RunTransactions(latch, LL, map)));
}
for (int i = 0; i < THREADS; i++) {
threads.get(i).start();
}
latch.countDown();
for (int i = 0; i < THREADS; i++) {
threads.get(i).join();
}
SortedSet<Integer> set = new TreeSet<>();
// go over map in ascending order of keys (so by version)
// System.out.print("\n");
for (Entry<Long, ArrayList<Pair>> entry : map.entrySet()) {
// System.out.print(entry.getKey() + ":");
ArrayList<Pair> ops = entry.getValue();
for (Pair p : ops) {
if (p.first) {
set.add(p.second);
} else {
set.remove(p.second);
}
}
}
// System.out.print("\n");
// LL.printLinkedListNotInTX();
// System.out.println(set.size() + " in set");
// System.out.print("-2147483648--");
// for (Integer k : set) {
// System.out.print(k + "--");
// }
// System.out.print("\n");
LNode node = LL.head.next;
for (Integer k : set) {
Assert.assertNotNull(node);
Assert.assertEquals(k, node.key);
node = node.next;
}
Assert.assertNull(node);
}
示例12: loadNextBatch
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
protected void loadNextBatch(){
if(currentRanges.isEmpty()){
noMoreBatches = true;
currentBatch = Collections.emptyList();
return;
}
currentBatchIndex = 0;
if(currentBatch != null){
T endOfLastBatch = CollectionTool.getLast(currentBatch);
if(endOfLastBatch == null){
currentBatch = null;
return;
}
PK lastRowOfPreviousBatch = getPrimaryKey(endOfLastBatch);
Range<PK> previousRange = null;
SortedSet<Range<PK>> remainingRanges = new TreeSet<>(currentRanges);
for(Range<PK> range : currentRanges){
if(previousRange != null){
if(range.getStart() == null || range.getStart().compareTo(lastRowOfPreviousBatch) > 0){
break;
}
remainingRanges.remove(previousRange);
if(!ranges.isEmpty()){
remainingRanges.add(ranges.pollFirst());
}
}
previousRange = range;
}
currentRanges = remainingRanges;
if(currentRanges.isEmpty()){
noMoreBatches = true;
currentBatch = Collections.emptyList();
return;
}
Range<PK> firstRange = currentRanges.first().clone();
firstRange.setStart(lastRowOfPreviousBatch);
firstRange.setStartInclusive(false);
currentRanges.remove(currentRanges.first());
if(!firstRange.isEmpty()){
currentRanges.add(firstRange);
}else if(currentRanges.isEmpty()){
noMoreBatches = true;
currentBatch = Collections.emptyList();
return;
}
}
int batchConfigLimit = this.config.getIterateBatchSize();
if(this.config.getLimit() != null && this.config.getLimit() - resultCount < batchConfigLimit){
batchConfigLimit = (int) (this.config.getLimit() - resultCount);
}
batchConfig.setLimit(batchConfigLimit);
currentBatch = doLoad(currentRanges, batchConfig);
while(currentBatch.isEmpty() && !ranges.isEmpty()){
currentRanges.clear();
for(int i = 0; i < RANGE_BATCH_SIZE && !ranges.isEmpty(); i++){
currentRanges.add(ranges.pollFirst());
}
currentBatch = doLoad(currentRanges, batchConfig);
}
batchConfig.setOffset(0);
resultCount += currentBatch.size();
if(ranges.size() == 0 && CollectionTool.size(currentBatch) < batchConfig.getLimit()
|| config.getLimit() != null && resultCount >= config.getLimit()){
noMoreBatches = true;//tell the advance() method not to call this method again
}
}
示例13: extractFormToImageGalleryItem
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Extract web form content to imageGallery item.
*
* @param request
* @param imageForm
* @throws ImageGalleryException
*/
private void extractFormToImageGalleryItem(HttpServletRequest request, ImageGalleryItemForm imageForm)
throws Exception {
/*
* BE CAREFUL: This method will copy necessary info from request form to an old or new ImageGalleryItem instance.
* It gets all info EXCEPT ImageGalleryItem.createDate and ImageGalleryItem.createBy, which need be set when
* persisting this imageGallery item.
*/
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(imageForm.getSessionMapID());
// check whether it is "edit(old item)" or "add(new item)"
SortedSet<ImageGalleryItem> imageList = getImageList(sessionMap);
int imageIdx = NumberUtils.stringToInt(imageForm.getImageIndex(), -1);
ImageGalleryItem image = null;
if (imageIdx == -1) { // add
image = new ImageGalleryItem();
image.setCreateDate(new Timestamp(new Date().getTime()));
int maxSeq = 1;
if (imageList != null && imageList.size() > 0) {
ImageGalleryItem last = imageList.last();
maxSeq = last.getSequenceId() + 1;
}
image.setSequenceId(maxSeq);
imageList.add(image);
} else { // edit
List<ImageGalleryItem> rList = new ArrayList<ImageGalleryItem>(imageList);
image = rList.get(imageIdx);
}
// uploadImageGalleryItemFile
// and setting file properties' fields: item.setFileUuid();
// item.setFileName();
if (imageForm.getFile() != null) {
// if it has old file, and upload a new, then save old to deleteList
ImageGalleryItem delImage = new ImageGalleryItem();
boolean hasOld = false;
if (image.getOriginalFileUuid() != null) {
hasOld = true;
// be careful, This new ImageGalleryItem object never be save into database
// just temporarily use for saving fileUuid and versionID use:
delImage.setOriginalFileUuid(image.getOriginalFileUuid());
}
IImageGalleryService service = getImageGalleryService();
try {
service.uploadImageGalleryItemFile(image, imageForm.getFile());
} catch (UploadImageGalleryFileException e) {
// if it is new add , then remove it!
if (imageIdx == -1) {
imageList.remove(image);
}
throw e;
}
// put it after "upload" to ensure deleted file added into list only no exception happens during upload
if (hasOld) {
List<ImageGalleryItem> delAtt = getDeletedItemAttachmentList(sessionMap);
delAtt.add(delImage);
}
}
String title = imageForm.getTitle();
if (StringUtils.isBlank(title)) {
Long nextImageTitleNumber = (Long) sessionMap.get(ImageGalleryConstants.ATTR_NEXT_IMAGE_TITLE);
sessionMap.put(ImageGalleryConstants.ATTR_NEXT_IMAGE_TITLE, nextImageTitleNumber + 1);
title = getImageGalleryService().generateNextImageTitle(nextImageTitleNumber);
}
image.setTitle(title);
image.setDescription(imageForm.getDescription());
image.setCreateByAuthor(true);
image.setHide(false);
}
示例14: extractMultipleFormToImageGalleryItems
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Extract web form content to imageGallery items.
*
* @param request
* @param multipleForm
* @throws ImageGalleryException
*/
private void extractMultipleFormToImageGalleryItems(HttpServletRequest request, MultipleImagesForm multipleForm)
throws Exception {
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(multipleForm.getSessionMapID());
// check whether it is "edit(old item)" or "add(new item)"
SortedSet<ImageGalleryItem> imageList = getImageList(sessionMap);
List<FormFile> fileList = ImageGalleryUtils.createFileListFromMultipleForm(multipleForm);
for (FormFile file : fileList) {
ImageGalleryItem image = new ImageGalleryItem();
image.setCreateDate(new Timestamp(new Date().getTime()));
int maxSeq = 1;
if (imageList != null && imageList.size() > 0) {
ImageGalleryItem last = imageList.last();
maxSeq = last.getSequenceId() + 1;
}
image.setSequenceId(maxSeq);
imageList.add(image);
// uploadImageGalleryItemFile
// and setting file properties' fields: item.setFileUuid();
// item.setFileName();
IImageGalleryService service = getImageGalleryService();
try {
service.uploadImageGalleryItemFile(image, file);
} catch (UploadImageGalleryFileException e) {
imageList.remove(image);
throw e;
}
Long nextImageTitleNumber = (Long) sessionMap.get(ImageGalleryConstants.ATTR_NEXT_IMAGE_TITLE);
sessionMap.put(ImageGalleryConstants.ATTR_NEXT_IMAGE_TITLE, nextImageTitleNumber + 1);
String title = getImageGalleryService().generateNextImageTitle(nextImageTitleNumber);
image.setTitle(title);
image.setDescription("");
image.setCreateByAuthor(true);
image.setHide(false);
}
}