ACCEPT's blog

By ACCEPT, 14 years ago, In English
is there any function in C++ for set, that return the i-th element of set in O(lgn) or return the place of an element in set?
for example given a set S= {7,8,9,10,11}, then firsrt function for call 2 return 8 and second function for call 8 return 2.
sorry for my very poooooooooooooooor english! 
Tags c++, set
  • Vote: I like it
  • +5
  • Vote: I do not like it

14 years ago, # |
  Vote: I like it 0 Vote: I do not like it
No, there isn't such functions. You need to implement your own balanced binary search tree for this.
14 years ago, # |
  Vote: I like it +18 Vote: I do not like it
I know a lot of people who tried to solve this with C++ set. Nobody has succeeded. :)
14 years ago, # |
  Vote: I like it +3 Vote: I do not like it
Suggestion for may be non-portable extension in the STL set class is here.
14 years ago, # |
  Vote: I like it +3 Vote: I do not like it
many thank's for all!