Open3D的open3d.core.HashSet类是一个哈希集合,它支持将元素插入、删除和查询。erase方法用于从集合中删除指定的元素。
erase(self, key: Union[float, int, numpy.float32, numpy.float64, numpy.int32, numpy.int64]) -> bool
参数说明:
key
: 要删除的元素的键返回值说明:
bool
: 如果删除成功,则返回True;否则返回False。import open3d.core as o3c
import numpy as np
#创建哈希集合
hashset = o3c.HashSet()
#往哈希集合中插入元素
hashset.insert(1)
hashset.insert(2)
hashset.insert(3)
#从哈希集合中删除元素
hashset.erase(2)
#查询元素是否存在于哈希集合中
print(hashset.contains(2)) # False
print(hashset.contains(1)) # True
print(hashset.contains(3)) # True
如果要删除的元素不存在于哈希集合中,则会引发KeyError
异常。