Set

Set 是一种用于保存不重复元素的数据结构。常被用作测试归属性,故其查找的性能十分重要。

编程实现

Python

Setpython自带的基本数据结构, 有多种初始化方式。 Pythonsetdict的Implementation方式类似, 可以认为set是只有keydict.

s = set()
s1 = {1, 2, 3}
s.add('shaunwei')
'shaun' in s  # return true
s.remove('shaunwei')

results matching ""

    No results matching ""