java.util.concurrent.ConcurrentSkipListMap的remove()方法是Java中的内置函数,该函数从此映射中删除指定键的映射。如果该特定键没有映射,则该方法返回null。执行此方法后,将减小Map的大小。
用法:
ConcurrentSkipListMap.remove(Object ob)
参数:该函数接受单个强制性参数ob,它指定要删除其映射的键。
返回值:该函数返回与指定键关联的先前值;如果键没有映射,则返回null。
以下示例程序旨在说明上述方法:
// Java Program Demonstrate remove()
// method of ConcurrentSkipListMap
import java.util.concurrent.*;
class GFG {
public static void main(String[] args)
{
// Initializing the map
ConcurrentSkipListMap<Integer, Integer>
mpp = new ConcurrentSkipListMap<Integer,
Integer>();
// Adding elements to this map
for (int i = 1; i <= 5; i++)
mpp.put(i, i);
// remove() operation on the map
mpp.remove(1);
System.out.println("After remove(): " + mpp);
}
}
输出:
After remove(): {2=2, 3=3, 4=4, 5=5}
示例2:
// Java Program Demonstrate remove()
// method of ConcurrentSkipListMap
import java.util.concurrent.*;
class GFG {
public static void main(String[] args)
{
// Initializing the map
ConcurrentSkipListMap<Integer, Integer>
mpp = new ConcurrentSkipListMap<Integer,
Integer>();
// Adding elements to this map
for (int i = 1; i <= 5; i++)
mpp.put(i, i);
// remove() operation on the map
mpp.remove(5);
System.out.println("After remove(): " + mpp);
}
}
输出:
After remove(): {1=1, 2=2, 3=3, 4=4}
相关用法
- Java ConcurrentSkipListMap put()用法及代码示例
- Java ConcurrentSkipListMap clone()用法及代码示例
- Java ConcurrentSkipListMap equals()用法及代码示例
- Java ConcurrentSkipListMap clear()用法及代码示例
- Java ConcurrentSkipListMap size()用法及代码示例
- Java ConcurrentSkipListMap containsKey()用法及代码示例
- Java ConcurrentSkipListMap containsValue()用法及代码示例
- Java ConcurrentSkipListMap isEmpty()用法及代码示例
- Java ConcurrentSkipListMap ceilingKey()用法及代码示例
- Java Set remove()用法及代码示例
- Java Map remove()用法及代码示例
- Java CopyOnWriteArrayList remove()用法及代码示例
- Java AbstractList remove()用法及代码示例
- Java AbstractMap remove()用法及代码示例
- Java AbstractSequentialList remove()用法及代码示例
注:本文由纯净天空筛选整理自Twinkl Bajaj大神的英文原创作品 ConcurrentSkipListMap remove() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。