Home >Backend Development >Python Tutorial >Explanation on the set--unordered feature

Explanation on the set--unordered feature

巴扎黑
巴扎黑Original
2017-07-19 13:18:571758browse

Unordered set is a container that stores unique elements in no specific order, which allows fast retrieval of each element based on its value.
In an unordered_set, an element's value is at the same time its key, identifying it uniquely. Keys are immutable, so elements in an unordered_set cannot be modified once in the container - they can be inserted or removed, though.
Internally, the elements of the unordered_set are sorted in any particular order, but organized according to their hash values ​​to allow fast access to individual elements directly by their values ​​(with average constant average time complexity ) value area.
Unordered_set containers can access individual elements by key faster than group containers, although they are generally inefficient for range iteration through a subset of their elements.

Iterators in containers are at least forward iterators.

Regarding the issue of set sorting being out of order, the reason is that set uses a hash table as a memory index.

Detailed introduction can be found at:


and wiki:


Explanation on the set--unordered feature

The above is the detailed content of Explanation on the set--unordered feature. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn