The g++ compiler also supports some data structures that are not part of the C++ standard library. Such structures are called policy-based data structures. These data structures are designed for high-performance, flexibility, semantic safety, and conformance to the corresponding containers in std.
To use these structures, the following lines must be added to the code:
For an example following is a code showing a policy-based data structure that is like set, it can add/remove elements, can find the number of elements less than x, kth smallest element etc in O(logn) time. It can also be indexed like an array. The specialty of this set is that we have access to the indices that the elements would have in a sorted array. If the element does not appear in the set, we get the position that the element would have in the set.
The value at 3rd index ::6 The index of number 6::3 The index of number seven ::4
NOTE:Both the functions order_of_key and find_by_order work in logarithmic time.