本文整理汇总了Java中java.util.NavigableSet.remove方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableSet.remove方法的具体用法?Java NavigableSet.remove怎么用?Java NavigableSet.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.NavigableSet
的用法示例。
在下文中一共展示了NavigableSet.remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: demoNavigableSetRemove
import java.util.NavigableSet; //导入方法依赖的package包/类
private static void demoNavigableSetRemove(NavigableSet<Integer> set) {
System.out.println("set: " + set);
try {
for (int i : set) {
System.out.println(i);
System.out.println("Calling set.remove(2)...");
set.remove(2);
}
} catch (Exception ex) {
System.out.println(ex.getClass().getName());
}
System.out.println("set: " + set);
}
示例2: testAsMapNavigableReadsThrough
import java.util.NavigableSet; //导入方法依赖的package包/类
@GwtIncompatible // NavigableMap
public void testAsMapNavigableReadsThrough() {
NavigableSet<String> strings = Sets.newTreeSet();
Collections.addAll(strings, "one", "two", "three");
NavigableMap<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();
NavigableMap<String, Integer> tailMap = map.tailMap("s", true);
NavigableMap<String, Integer> subMap = map.subMap("a", true, "t", false);
strings.add("six");
strings.remove("two");
assertThat(tailMap.entrySet()).containsExactly(
mapEntry("six", 3),
mapEntry("three", 5)).inOrder();
assertThat(subMap.entrySet()).containsExactly(
mapEntry("five", 4),
mapEntry("four", 4),
mapEntry("six", 3)).inOrder();
}
示例3: remove
import java.util.NavigableSet; //导入方法依赖的package包/类
void remove(NavigableSet<Integer> set, int element) {
if (set.remove(element))
bs.clear(element);
}
示例4: remove
import java.util.NavigableSet; //导入方法依赖的package包/类
void remove(NavigableSet<Integer> set, int element, BitSet bs) {
if (set.remove(element))
bs.clear(element);
}