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.
- Data type of character constants in C and C++
- Initialization of data members
- Static data members in C++
- Can we access private data members of a class without using a member or a friend function?
- Data Type Ranges and their macros in C++
- Conversion of Struct data type to Hex String and vice versa
- Difference between C structures and C++ structures
- C++ Data Types
- How to store Data Triplet in a Vector in C++?
- Bool data type in C++
- Comparison of boolean data type in C++ and Java
- std::string::data() in C++
- Range-based for loop in C++
- C++ set for user define data type
- Interesting facts about data-types and modifiers in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.