简体   繁体   中英

Does OrderedSet() still have a search parameter of O(1)?

I have heard that when you perform an in operator on a list it has to search through O(n) objects while if you do it on a set it has to search through O(1) objects. To see what I mean go here . Does this still apply to OrderedSet ?

Which OrderedSet are you talking about? At this time (Python 3.8.3), there is not OrderedSet in the standard library.

Typically , OrderedSet implementations will implement __contains__ by delegating to the underlying set . So it will have the algorithmic complexity you would expect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM