本文整理匯總了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);
}