本文整理汇总了Java中java.util.TreeSet.remove方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSet.remove方法的具体用法?Java TreeSet.remove怎么用?Java TreeSet.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.TreeSet
的用法示例。
在下文中一共展示了TreeSet.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remove
import java.util.TreeSet; //导入方法依赖的package包/类
protected void remove(XOffering offering, boolean removeExpectations) {
Lock lock = writeLock();
try {
for (XCourse course: offering.getCourses()) {
iCourseForId.remove(course.getCourseId());
TreeSet<XCourseId> courses = iCourseForName.get(course.getCourseNameInLowerCase());
if (courses != null) {
courses.remove(course);
if (courses.size() == 1)
for (XCourseId x: courses) x.setHasUniqueName(true);
if (courses.isEmpty())
iCourseForName.remove(course.getCourseNameInLowerCase());
}
}
iOfferingTable.remove(offering.getOfferingId());
if (removeExpectations)
iExpectations.remove(offering.getOfferingId());
for (String externalId: offering.getInstructorExternalIds()) {
Set<Long> offeringIds = iInstructedOfferings.get(externalId);
if (offeringIds != null) offeringIds.remove(offering.getOfferingId());
}
} finally {
lock.release();
}
}
示例2: getLocalesList
import java.util.TreeSet; //导入方法依赖的package包/类
public ArrayList<LocaleRenderer> getLocalesList(final Activity activity) {
final TreeSet<String> locales = UserDictionaryList.getUserDictionaryLocalesSet(activity);
// Remove our locale if it's in, because we're always gonna put it at the top
locales.remove(mLocale); // mLocale may not be null
final String systemLocale = Locale.getDefault().toString();
// The system locale should be inside. We want it at the 2nd spot.
locales.remove(systemLocale); // system locale may not be null
locales.remove(""); // Remove the empty string if it's there
final ArrayList<LocaleRenderer> localesList = new ArrayList<>();
// Add the passed locale, then the system locale at the top of the list. Add an
// "all languages" entry at the bottom of the list.
addLocaleDisplayNameToList(activity, localesList, mLocale);
if (!systemLocale.equals(mLocale)) {
addLocaleDisplayNameToList(activity, localesList, systemLocale);
}
for (final String l : locales) {
// TODO: sort in unicode order
addLocaleDisplayNameToList(activity, localesList, l);
}
if (!"".equals(mLocale)) {
// If mLocale is "", then we already inserted the "all languages" item, so don't do it
addLocaleDisplayNameToList(activity, localesList, ""); // meaning: all languages
}
localesList.add(new LocaleRenderer(activity, null)); // meaning: select another locale
return localesList;
}
示例3: computeTryAllAssignments
import java.util.TreeSet; //导入方法依赖的package包/类
public void computeTryAllAssignments() {
iAllAssignments = new TreeSet();
Placement current = iAssignment.getValue(iLecture);
for (Placement p: iLecture.values(iAssignment)) {
if (p.equals(current)) continue;
if (p.isHard(iAssignment) && !iAllowBreakHard) continue;
if (!match(p)) continue;
if (iSameTime && current!=null && !p.getTimeLocation().equals(((Placement)current).getTimeLocation())) continue;
if (iSameRoom && current!=null && !p.sameRooms((Placement)current)) continue;
if (iAllAssignments.size()==iLimit && ((Suggestion)iAllAssignments.last()).isBetter(iSolver)) continue;
Suggestion s = tryAssignment(p);
if (s != null)
iAllAssignments.add(s);
if (iAllAssignments.size()>iLimit) iAllAssignments.remove(iAllAssignments.last());
}
}
示例4: removeFromNeverSaveList
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* Removes the specified list of authentication domains from the never save list.
* @throws IOException if the credential storage metadata cannot be modified.
*/
public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
CredentialMeta meta = readCredentialMeta();
TreeSet<String> neverSaveDomains = new TreeSet<>();
for (String neverSaveDomain : meta.getNeverSaveList()) {
neverSaveDomains.add(neverSaveDomain);
}
for (AuthenticationDomain authDomain : authDomains) {
neverSaveDomains.remove(authDomain.toString());
}
writeCredentialMeta(
meta.toBuilder()
.clearNeverSave()
.addAllNeverSave(neverSaveDomains)
.build());
}
示例5: assignPartition
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* @return the consumer to which the given partition is assigned. The assignment should improve the overall balance
* of the partition assignments to consumers.
*/
private String assignPartition(TopicPartition partition,
TreeSet<String> sortedCurrentSubscriptions,
Map<String, List<TopicPartition>> currentAssignment,
Map<String, List<TopicPartition>> consumer2AllPotentialPartitions,
Map<TopicPartition, String> currentPartitionConsumer) {
for (String consumer: sortedCurrentSubscriptions) {
if (consumer2AllPotentialPartitions.get(consumer).contains(partition)) {
sortedCurrentSubscriptions.remove(consumer);
currentAssignment.get(consumer).add(partition);
currentPartitionConsumer.put(partition, consumer);
sortedCurrentSubscriptions.add(consumer);
return consumer;
}
}
return null;
}
示例6: main
import java.util.TreeSet; //导入方法依赖的package包/类
public static void main(String[] args) {
Scanner scann = new Scanner(System.in);
TreeSet<String> gests = new TreeSet();
int invitations = 0;
String input = scann.nextLine();
while(!input.equals("PARTY")){
gests.add(input);
input = scann.nextLine();
}
invitations = gests.size();
input = scann.nextLine();
while(!input.equals("END")){
--invitations;
gests.remove(input);
input = scann.nextLine();
}
System.out.println(invitations);
for (String gest :
gests ) {
System.out.println(gest);
}
}
示例7: replaceVariantContextsInMap
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* Update the event maps in all haplotypes to replace a replacement of update1 and 2 with replacement
*
* @param haplotypes the haplotypes whose event maps we need to update
* @param startPosKeySet a sorted set of start positions that we must update
* @param replacement a VariantContext to replace update1 and update2 with. Can be null, indicating that we just want to remove update1 and update2
* @param update1 the first VC we want to update
* @param update2 the second VC we want to update
*/
private void replaceVariantContextsInMap(final List<Haplotype> haplotypes,
final TreeSet<Integer> startPosKeySet,
final VariantContext replacement,
final VariantContext update1, final VariantContext update2) {
// remove the old event from the eventMap on every haplotype and the start pos key set, replace with merged event
for( final Haplotype h : haplotypes ) {
// if we had both events, add replacement. In some cases the haplotype may not have both
// events but they were still merged because the haplotype isn't a particularly informative
// haplotype in any case. The order of operations here is important because we are modifying the map
final boolean shouldAdd = h.getEventMap().containsKey(update1.getStart()) && h.getEventMap().containsKey(update2.getStart());
h.getEventMap().remove(update1.getStart());
h.getEventMap().remove(update2.getStart());
if ( shouldAdd && replacement != null ) {
h.getEventMap().addVC(replacement, false); // cannot merge we other events at the same position
}
}
startPosKeySet.remove(update1.getStart());
startPosKeySet.remove(update2.getStart());
if ( replacement != null ) startPosKeySet.add(replacement.getStart());
}
示例8: getAllPackages
import java.util.TreeSet; //导入方法依赖的package包/类
private TreeSet<String> getAllPackages(FileObject root) {
TreeSet<String> toRet = new TreeSet<String>();
processFolder(root, root, toRet);
toRet.remove("");
return toRet;
}
示例9: remove
import java.util.TreeSet; //导入方法依赖的package包/类
public boolean remove(Object e)
{
TreeSet<E> item = new TreeSet<E>(comparator());
item.add((E)e);
TreeSet<E> target = other.floor(item);
if(target != null && other.comparator().compare(item, target) == 0)
{
if(target.size() == 1)
other.remove(target);
else
target.remove(e);
}
return super.remove(e);
}
示例10: removeTag
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* Remove a tag from 'mapTag'.
*
* @param id id of the tag
* @param tag String of the tag
*/
private void removeTag(final Long id, final String tag) {
final TreeSet<Long> tempSet = mapTag.get(tag);
tempSet.remove(id);
if (tempSet.isEmpty()) {
mapTag.remove(tag);
} else {
mapTag.put(tag, tempSet);
}
}
示例11: findBestServers
import java.util.TreeSet; //导入方法依赖的package包/类
private List/* <LoadHolder> */ findBestServers(Map groupServers, Set excludedServers, int count) {
TreeSet bestEntries = new TreeSet(new Comparator() {
public int compare(Object o1, Object o2) {
LoadHolder l1 = (LoadHolder) o1;
LoadHolder l2 = (LoadHolder) o2;
int difference = Float.compare(l1.getLoad(), l2.getLoad());
if (difference != 0) {
return difference;
}
ServerLocation sl1 = l1.getLocation();
ServerLocation sl2 = l2.getLocation();
return sl1.compareTo(sl2);
}
});
float lastBestLoad = Float.MAX_VALUE;
for (Iterator itr = groupServers.entrySet().iterator(); itr.hasNext();) {
Map.Entry next = (Entry) itr.next();
ServerLocation location = (ServerLocation) next.getKey();
if (excludedServers.contains(location)) {
continue;
}
LoadHolder nextLoadReference = (LoadHolder) next.getValue();
float nextLoad = nextLoadReference.getLoad();
if (bestEntries.size() < count || count == -1 || nextLoad < lastBestLoad) {
bestEntries.add(nextLoadReference);
if (count != -1 && bestEntries.size() > count) {
bestEntries.remove(bestEntries.last());
}
LoadHolder lastBestHolder = (LoadHolder) bestEntries.last();
lastBestLoad = lastBestHolder.getLoad();
}
}
return new ArrayList(bestEntries);
}
示例12: writePartitions
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* Write out a {@link SequenceFile} that can be read by
* {@link TotalOrderPartitioner} that contains the split points in startKeys.
*/
@SuppressWarnings("deprecation")
private static void writePartitions(Configuration conf, Path partitionsPath,
List<ImmutableBytesWritable> startKeys) throws IOException {
LOG.info("Writing partition information to " + partitionsPath);
if (startKeys.isEmpty()) {
throw new IllegalArgumentException("No regions passed");
}
// We're generating a list of split points, and we don't ever
// have keys < the first region (which has an empty start key)
// so we need to remove it. Otherwise we would end up with an
// empty reducer with index 0
TreeSet<ImmutableBytesWritable> sorted =
new TreeSet<ImmutableBytesWritable>(startKeys);
ImmutableBytesWritable first = sorted.first();
if (!first.equals(HConstants.EMPTY_BYTE_ARRAY)) {
throw new IllegalArgumentException(
"First region of table should have empty start key. Instead has: "
+ Bytes.toStringBinary(first.get()));
}
sorted.remove(first);
// Write the actual file
FileSystem fs = partitionsPath.getFileSystem(conf);
SequenceFile.Writer writer = SequenceFile.createWriter(
fs, conf, partitionsPath, ImmutableBytesWritable.class,
NullWritable.class);
try {
for (ImmutableBytesWritable startKey : sorted) {
writer.append(startKey, NullWritable.get());
}
} finally {
writer.close();
}
}
示例13: getShortestPath
import java.util.TreeSet; //导入方法依赖的package包/类
public static java.util.ArrayList<Vector> getShortestPath(Vector start, Vector end, Dijkstra.Description desc)
{
TreeSet<Vector> closedSet = new TreeSet<Vector>();
TreeSet<FVWrapper> openSet = new TreeSet<FVWrapper>();
openSet.add(new FVWrapper(start, heuristic(start, end)));
TreeMap<Vector, Vector> cameFrom = new TreeMap<Vector, Vector>();
TreeMap<Vector, Double> gScore = new TreeMap<Vector, Double>();
gScore.put(start, 0.0);
TreeMap<Vector, Double> fScore = new TreeMap<Vector, Double>();
fScore.put(start, heuristic(start, end));
while(!openSet.isEmpty())
{
FVWrapper current = openSet.first();
openSet.remove(current);
if(current.v.equals(end))
return getReturn(cameFrom, current.v);
closedSet.add(current.v);
java.util.List<Vector> neighbor = desc.getNeighbor(current.v);
for(int i = 0 ; i < neighbor.size() ; i++)
{
Vector nei = neighbor.get(i);
if(!closedSet.contains(nei))
{
FVWrapper neiOpen = new FVWrapper(nei, null);
double tenative = gScore.get(current.v) + current.v.skew(nei);
Double g = gScore.get(nei);
g = g == null? Triangle.LARGE_VALUE : g;
if(tenative < g)
{
cameFrom.put(nei, current.v);
gScore.put(nei, tenative);
double f = g + heuristic(nei, end);
fScore.put(nei, f);
neiOpen.fScore = f;
}
openSet.add(neiOpen);
}
}
}
return null;
}
示例14: testTailSetTreeSet
import java.util.TreeSet; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testTailSetTreeSet() {
TreeSet<Integer> set = new TreeSet<Integer>();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
set.add(5);
SortedSet<Integer> hs = set.tailSet(3);
hs.add(10);
assertThat(hs).containsExactly(3, 4, 5, 10);
set.remove(4);
assertThat(hs).containsExactly(3, 5, 10);
set.remove(3);
assertThat(hs).containsExactly(5, 10);
hs.add(-1);
}
示例15: testHeadSetTreeSet
import java.util.TreeSet; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testHeadSetTreeSet() {
TreeSet<Integer> set = new TreeSet<Integer>();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
set.add(5);
SortedSet<Integer> hs = set.headSet(3);
hs.add(0);
assertThat(hs).containsExactly(0, 1, 2);
set.remove(2);
assertThat(hs).containsExactly(0, 1);
set.remove(3);
assertThat(hs).containsExactly(0, 1);
hs.add(7);
}