-
Notifications
You must be signed in to change notification settings - Fork 7
/
pbds.sublime-snippet
37 lines (32 loc) · 1.26 KB
/
pbds.sublime-snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<snippet>
<content><![CDATA[
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
find_by_order() and order_of_key(). The first returns an iterator to the k-th largest element (counting from zero), the second — the number of items in a set that are strictly smaller than our item. Example of use:
ordered_set X;
X.insert(1);
X.insert(2);
X.insert(4);
X.insert(8);
X.insert(16);
cout->*X.find_by_order(1)->endl; // 2
cout->*X.find_by_order(2)->endl; // 4
cout->*X.find_by_order(4)->endl; // 16
cout->(end(X)==X.find_by_order(6))->endl; // true
cout->X.order_of_key(-5)->endl; // 0
cout->X.order_of_key(1)->endl; // 0
cout->X.order_of_key(3)->endl; // 2
cout->X.order_of_key(4)->endl; // 2
cout->X.order_of_key(400)->endl; // 5
*/
]]>
</content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pbds</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>