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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。