line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include "string.h" |
3
|
|
|
|
|
|
|
#include "string_view.h" |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
/* |
9
|
|
|
|
|
|
|
* panda::string_set and panda::string_multiset are wrappers around STL's versions in case if keys are panda::string. |
10
|
|
|
|
|
|
|
* The goal is to make it possible to call some STL's methods with string_view |
11
|
|
|
|
|
|
|
*/ |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
namespace panda { |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
template , class Allocator = std::allocator> |
16
|
24
|
|
|
|
|
|
class string_set : public std::set { |
17
|
|
|
|
|
|
|
private: |
18
|
|
|
|
|
|
|
template |
19
|
|
|
|
|
|
|
static inline std::true_type _is_base_string (panda::basic_string const volatile) { return std::true_type(); } |
20
|
|
|
|
|
|
|
static inline std::false_type _is_base_string (...) { return std::false_type(); } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
static_assert(decltype(_is_base_string(Key()))::value, "Key must be based on panda::basic_string"); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
using Base = std::set; |
25
|
|
|
|
|
|
|
using SVKey = basic_string_view; |
26
|
|
|
|
|
|
|
|
27
|
18
|
|
|
|
|
|
static Key _key_from_sv (const SVKey& key) { |
28
|
|
|
|
|
|
|
typedef typename Key::value_type FakeCharLiteral[1]; |
29
|
18
|
|
|
|
|
|
Key tmp(*(const FakeCharLiteral*)key.data()); |
30
|
18
|
|
|
|
|
|
tmp.length(key.length()); |
31
|
18
|
|
|
|
|
|
return tmp; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
public: |
34
|
|
|
|
|
|
|
using typename Base::key_type; |
35
|
|
|
|
|
|
|
using typename Base::value_type; |
36
|
|
|
|
|
|
|
using typename Base::size_type; |
37
|
|
|
|
|
|
|
using typename Base::difference_type; |
38
|
|
|
|
|
|
|
using typename Base::key_compare; |
39
|
|
|
|
|
|
|
using typename Base::allocator_type; |
40
|
|
|
|
|
|
|
using typename Base::reference; |
41
|
|
|
|
|
|
|
using typename Base::const_reference; |
42
|
|
|
|
|
|
|
using typename Base::pointer; |
43
|
|
|
|
|
|
|
using typename Base::const_pointer; |
44
|
|
|
|
|
|
|
using typename Base::iterator; |
45
|
|
|
|
|
|
|
using typename Base::const_iterator; |
46
|
|
|
|
|
|
|
using typename Base::reverse_iterator; |
47
|
|
|
|
|
|
|
using typename Base::const_reverse_iterator; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
using Base::Base; |
50
|
|
|
|
|
|
|
using Base::find; |
51
|
|
|
|
|
|
|
using Base::count; |
52
|
|
|
|
|
|
|
using Base::erase; |
53
|
|
|
|
|
|
|
using Base::equal_range; |
54
|
|
|
|
|
|
|
using Base::lower_bound; |
55
|
|
|
|
|
|
|
using Base::upper_bound; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
template ::value>::type> |
58
|
5
|
50
|
|
|
|
|
iterator find (X key) { return find(_key_from_sv(key)); } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
template ::value>::type> |
61
|
|
|
|
|
|
|
const_iterator find (X key) const { return find(_key_from_sv(key)); } |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
template ::value>::type> |
64
|
3
|
50
|
|
|
|
|
size_type count (X key) const { return count(_key_from_sv(key)); } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
template ::value>::type> |
67
|
3
|
50
|
|
|
|
|
size_type erase (X key) { return erase(_key_from_sv(key)); } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
template ::value>::type> |
70
|
3
|
50
|
|
|
|
|
std::pair equal_range (X key) { return equal_range(_key_from_sv(key)); } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
template ::value>::type> |
73
|
|
|
|
|
|
|
std::pair equal_range (X key) const { return equal_range(_key_from_sv(key)); } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
template ::value>::type> |
76
|
2
|
50
|
|
|
|
|
iterator lower_bound (X key) { return lower_bound(_key_from_sv(key)); } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
template ::value>::type> |
79
|
|
|
|
|
|
|
const_iterator lower_bound (X key) const { return lower_bound(_key_from_sv(key)); } |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
template ::value>::type> |
82
|
2
|
50
|
|
|
|
|
iterator upper_bound (X key) { return upper_bound(_key_from_sv(key)); } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
template ::value>::type> |
85
|
|
|
|
|
|
|
const_iterator upper_bound (X key) const { return upper_bound(_key_from_sv(key)); } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
template , class Allocator = std::allocator> |
90
|
24
|
|
|
|
|
|
class string_multiset : public std::multiset { |
91
|
|
|
|
|
|
|
private: |
92
|
|
|
|
|
|
|
template |
93
|
|
|
|
|
|
|
static inline std::true_type _is_base_string (panda::basic_string const volatile) { return std::true_type(); } |
94
|
|
|
|
|
|
|
static inline std::false_type _is_base_string (...) { return std::false_type(); } |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
static_assert(decltype(_is_base_string(Key()))::value, "Key must be based on panda::basic_string"); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
using Base = std::multiset; |
99
|
|
|
|
|
|
|
using SVKey = basic_string_view; |
100
|
|
|
|
|
|
|
|
101
|
18
|
|
|
|
|
|
static Key _key_from_sv (const SVKey& key) { |
102
|
|
|
|
|
|
|
typedef typename Key::value_type FakeCharLiteral[1]; |
103
|
18
|
|
|
|
|
|
Key tmp(*(const FakeCharLiteral*)key.data()); |
104
|
18
|
|
|
|
|
|
tmp.length(key.length()); |
105
|
18
|
|
|
|
|
|
return tmp; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
public: |
108
|
|
|
|
|
|
|
using typename Base::key_type; |
109
|
|
|
|
|
|
|
using typename Base::value_type; |
110
|
|
|
|
|
|
|
using typename Base::size_type; |
111
|
|
|
|
|
|
|
using typename Base::difference_type; |
112
|
|
|
|
|
|
|
using typename Base::key_compare; |
113
|
|
|
|
|
|
|
using typename Base::allocator_type; |
114
|
|
|
|
|
|
|
using typename Base::reference; |
115
|
|
|
|
|
|
|
using typename Base::const_reference; |
116
|
|
|
|
|
|
|
using typename Base::pointer; |
117
|
|
|
|
|
|
|
using typename Base::const_pointer; |
118
|
|
|
|
|
|
|
using typename Base::iterator; |
119
|
|
|
|
|
|
|
using typename Base::const_iterator; |
120
|
|
|
|
|
|
|
using typename Base::reverse_iterator; |
121
|
|
|
|
|
|
|
using typename Base::const_reverse_iterator; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
using Base::Base; |
124
|
|
|
|
|
|
|
using Base::find; |
125
|
|
|
|
|
|
|
using Base::count; |
126
|
|
|
|
|
|
|
using Base::erase; |
127
|
|
|
|
|
|
|
using Base::equal_range; |
128
|
|
|
|
|
|
|
using Base::lower_bound; |
129
|
|
|
|
|
|
|
using Base::upper_bound; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
template ::value>::type> |
132
|
5
|
50
|
|
|
|
|
iterator find (X key) { return find(_key_from_sv(key)); } |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
template ::value>::type> |
135
|
|
|
|
|
|
|
const_iterator find (X key) const { return find(_key_from_sv(key)); } |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
template ::value>::type> |
138
|
3
|
50
|
|
|
|
|
size_type count (X key) const { return count(_key_from_sv(key)); } |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
template ::value>::type> |
141
|
3
|
50
|
|
|
|
|
size_type erase (X key) { return erase(_key_from_sv(key)); } |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
template ::value>::type> |
144
|
3
|
50
|
|
|
|
|
std::pair equal_range (X key) { return equal_range(_key_from_sv(key)); } |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
template ::value>::type> |
147
|
|
|
|
|
|
|
std::pair equal_range (X key) const { return equal_range(_key_from_sv(key)); } |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
template ::value>::type> |
150
|
2
|
50
|
|
|
|
|
iterator lower_bound (X key) { return lower_bound(_key_from_sv(key)); } |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
template ::value>::type> |
153
|
|
|
|
|
|
|
const_iterator lower_bound (X key) const { return lower_bound(_key_from_sv(key)); } |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
template ::value>::type> |
156
|
2
|
50
|
|
|
|
|
iterator upper_bound (X key) { return upper_bound(_key_from_sv(key)); } |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
template ::value>::type> |
159
|
|
|
|
|
|
|
const_iterator upper_bound (X key) const { return upper_bound(_key_from_sv(key)); } |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
}; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |