Introduction to pb_ds

The full name of the pb_ds library is Policy-Based Data Structures.

The pb_ds library wraps many data structures, such as hash tables, balanced binary trees, tries, and heaps (priority queues).

Like vector, set, and map, its components comply with the relevant STL interface specifications. Some components (such as priority queues) include all the functionality of their STL counterparts while providing more functionality than the STL.

pb_ds can only be used with compilers that use libstdc++ as their standard library.

You can use begin() and end() to obtain an iterator and traverse the structure.

You can increase_key, decrease_key, and delete individual elements.

Because the main contents of the pb_ds library are in the __gnu_pbds namespace, which begins with an underscore, its compliance in NOI-series activities has long been uncertain. On September 1, 2021, according to Supplementary Notes on Restrictions on the Use of Programming Languages in NOI-Series Activities, library functions or macros beginning with an underscore are allowed (except those with explicitly prohibited operations), providing documentary grounds for using the pb_ds library in NOI-series activities.

Reference: Application of the C++ pb_ds Library in OI

This content comes from OI Wiki: Introduction to pb_ds. See the original for authors and revision history. AIOJ has adapted the formatting, in-site links, and resource paths.

Content is shared under CC BY-SA 4.0 and SATA license; additional terms are governed by the original notice. Thanks to the OI Wiki authors and contributors; per the SATA terms, please visit the OI Wiki repository and star it to show your support.