tlx
Loading...
Searching...
No Matches
strings_parallel.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * tlx/sort/strings_parallel.hpp
3 *
4 * Front-end for parallel string sorting algorithms.
5 *
6 * Part of tlx - http://panthema.net/tlx
7 *
8 * Copyright (C) 2019 Timo Bingmann <tb@panthema.net>
9 *
10 * All rights reserved. Published under the Boost Software License, Version 1.0
11 ******************************************************************************/
12
13#ifndef TLX_SORT_STRINGS_PARALLEL_HEADER
14#define TLX_SORT_STRINGS_PARALLEL_HEADER
15
17
18#include <cstdint>
19#include <string>
20#include <vector>
21
22namespace tlx {
23
24//! \addtogroup tlx_sort
25//! \{
26//! \name String Sorting Algorithms
27//! \{
28
29/******************************************************************************/
30
31/*!
32 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
33 *
34 * The memory limit is currently not used.
35 */
36static inline
37void sort_strings_parallel(unsigned char** strings, size_t size,
38 size_t memory = 0) {
41 sort_strings_detail::UCharStringSet(strings, strings + size)),
42 /* depth */ 0, memory);
43}
44
45/*!
46 * Sort a set of strings in parallel represented by C-style char* in place.
47 *
48 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
49 * The memory limit is currently not used.
50 */
51static inline
52void sort_strings_parallel(char** strings, size_t size, size_t memory = 0) {
54 reinterpret_cast<unsigned char**>(strings), size, memory);
55}
56
57/*!
58 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
59 *
60 * The memory limit is currently not used.
61 */
62static inline
63void sort_strings_parallel(const unsigned char** strings, size_t size,
64 size_t memory = 0) {
67 sort_strings_detail::CUCharStringSet(strings, strings + size)),
68 /* depth */ 0, memory);
69}
70
71/*!
72 * Sort a set of strings in parallel represented by C-style char* in place.
73 *
74 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
75 * The memory limit is currently not used.
76 */
77static inline
78void sort_strings_parallel(const char** strings, size_t size,
79 size_t memory = 0) {
81 reinterpret_cast<const unsigned char**>(strings), size, memory);
82}
83
84/******************************************************************************/
85
86/*!
87 * Sort a set of strings in parallel represented by C-style char* in place.
88 *
89 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
90 * The memory limit is currently not used.
91 */
92static inline
93void sort_strings_parallel(std::vector<char*>& strings, size_t memory = 0) {
94 return sort_strings_parallel(strings.data(), strings.size(), memory);
95}
96
97/*!
98 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
99 *
100 * The memory limit is currently not used.
101 */
102static inline
103void sort_strings_parallel(std::vector<unsigned char*>& strings,
104 size_t memory = 0) {
105 return sort_strings_parallel(strings.data(), strings.size(), memory);
106}
107
108/*!
109 * Sort a set of strings in parallel represented by C-style char* in place.
110 *
111 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
112 * The memory limit is currently not used.
113 */
114static inline
115void sort_strings_parallel(std::vector<const char*>& strings,
116 size_t memory = 0) {
117 return sort_strings_parallel(strings.data(), strings.size(), memory);
118}
119
120/*!
121 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
122 *
123 * The memory limit is currently not used.
124 */
125static inline
126void sort_strings_parallel(std::vector<const unsigned char*>& strings,
127 size_t memory = 0) {
128 return sort_strings_parallel(strings.data(), strings.size(), memory);
129}
130
131/******************************************************************************/
132
133/*!
134 * Sort a set of std::strings in place in parallel.
135 *
136 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
137 * The memory limit is currently not used.
138 */
139static inline
140void sort_strings_parallel(std::string* strings, size_t size,
141 size_t memory = 0) {
144 sort_strings_detail::StdStringSet(strings, strings + size)),
145 /* depth */ 0, memory);
146}
147
148/*!
149 * Sort a vector of std::strings in place in parallel.
150 *
151 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
152 * The memory limit is currently not used.
153 */
154static inline
155void sort_strings_parallel(std::vector<std::string>& strings,
156 size_t memory = 0) {
157 return sort_strings_parallel(strings.data(), strings.size(), memory);
158}
159
160/******************************************************************************/
161/******************************************************************************/
162/******************************************************************************/
163
164/*!
165 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
166 *
167 * The memory limit is currently not used.
168 */
169static inline
170void sort_strings_parallel_lcp(unsigned char** strings, size_t size,
171 uint32_t* lcp, size_t memory = 0) {
175 sort_strings_detail::UCharStringSet(strings, strings + size), lcp),
176 /* depth */ 0, memory);
177}
178
179/*!
180 * Sort a set of strings in parallel represented by C-style char* in place.
181 *
182 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
183 * The memory limit is currently not used.
184 */
185static inline
186void sort_strings_parallel_lcp(char** strings, size_t size, uint32_t* lcp,
187 size_t memory = 0) {
189 reinterpret_cast<unsigned char**>(strings), size, lcp, memory);
190}
191
192/*!
193 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
194 *
195 * The memory limit is currently not used.
196 */
197static inline
198void sort_strings_parallel_lcp(const unsigned char** strings, size_t size,
199 uint32_t* lcp, size_t memory = 0) {
203 sort_strings_detail::CUCharStringSet(strings, strings + size), lcp),
204 /* depth */ 0, memory);
205}
206
207/*!
208 * Sort a set of strings in parallel represented by C-style char* in place.
209 *
210 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
211 * The memory limit is currently not used.
212 */
213static inline
214void sort_strings_parallel_lcp(const char** strings, size_t size,
215 uint32_t* lcp, size_t memory = 0) {
217 reinterpret_cast<const unsigned char**>(strings), size, lcp, memory);
218}
219
220/******************************************************************************/
221
222/*!
223 * Sort a set of strings in parallel represented by C-style char* in place.
224 *
225 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
226 * The memory limit is currently not used.
227 */
228static inline
229void sort_strings_parallel_lcp(std::vector<char*>& strings, uint32_t* lcp,
230 size_t memory = 0) {
232 strings.data(), strings.size(), lcp, memory);
233}
234
235/*!
236 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
237 *
238 * The memory limit is currently not used.
239 */
240static inline
241void sort_strings_parallel_lcp(std::vector<unsigned char*>& strings,
242 uint32_t* lcp, size_t memory = 0) {
244 strings.data(), strings.size(), lcp, memory);
245}
246
247/*!
248 * Sort a set of strings in parallel represented by C-style char* in place.
249 *
250 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
251 * The memory limit is currently not used.
252 */
253static inline
254void sort_strings_parallel_lcp(std::vector<const char*>& strings, uint32_t* lcp,
255 size_t memory = 0) {
257 strings.data(), strings.size(), lcp, memory);
258}
259
260/*!
261 * Sort a set of strings in parallel represented by C-style uint8_t* in place.
262 *
263 * The memory limit is currently not used.
264 */
265static inline
266void sort_strings_parallel_lcp(std::vector<const unsigned char*>& strings,
267 uint32_t* lcp, size_t memory = 0) {
269 strings.data(), strings.size(), lcp, memory);
270}
271
272/******************************************************************************/
273
274/*!
275 * Sort a set of std::strings in place in parallel.
276 *
277 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
278 * The memory limit is currently not used.
279 */
280static inline
281void sort_strings_parallel_lcp(std::string* strings, size_t size,
282 uint32_t* lcp, size_t memory = 0) {
286 sort_strings_detail::StdStringSet(strings, strings + size), lcp),
287 /* depth */ 0, memory);
288}
289
290/*!
291 * Sort a vector of std::strings in place in parallel.
292 *
293 * The strings are sorted as _unsigned_ 8-bit characters, not signed characters!
294 * The memory limit is currently not used.
295 */
296static inline
297void sort_strings_parallel_lcp(std::vector<std::string>& strings,
298 uint32_t* lcp, size_t memory = 0) {
300 strings.data(), strings.size(), lcp, memory);
301}
302
303/******************************************************************************/
304
305//! \}
306//! \}
307
308} // namespace tlx
309
310#endif // !TLX_SORT_STRINGS_PARALLEL_HEADER
311
312/******************************************************************************/
Class implementing StringSet concept for char* and unsigned char* strings.
Definition: string_set.hpp:301
Class implementing StringSet concept for arrays of std::string objects.
Definition: string_set.hpp:397
Objectified string and LCP array pointer arrays.
Definition: string_ptr.hpp:98
Objectified string array pointer array.
Definition: string_ptr.hpp:48
static void sort_strings_parallel_lcp(unsigned char **strings, size_t size, uint32_t *lcp, size_t memory=0)
Sort a set of strings in parallel represented by C-style uint8_t* in place.
static void sort_strings_parallel(unsigned char **strings, size_t size, size_t memory=0)
Sort a set of strings in parallel represented by C-style uint8_t* in place.
void parallel_sample_sort(const StringPtr &strptr, size_t depth, size_t memory)
Parallel Sample Sort Function with default parameter size for a generic StringSet.