Rust High Performance
上QQ阅读APP看书,第一时间看更新

Sets

Both HashMap and BTreeMap have their set counterparts, called HashSet and BTreeSet. Both are implemented with the same idea in mind: sometimes you don't need a key/value store, but just an element store, where you can retrieve the list of the elements by iterating through them, or where you can check whether an element is inside just by comparing it to the ones inside.

Their approach is the same as with the case of their map counterparts, and you can think of them as their counterpart maps but with a null value, where only keys are the ones doing the job.