20 #ifndef TLX_SORT_STRINGS_STRING_PTR_HEADER 21 #define TLX_SORT_STRINGS_STRING_PTR_HEADER 34 namespace sort_strings_detail {
36 template <
typename StringSet_>
39 template <
typename StringSet_,
typename LcpType_>
46 template <
typename StringSet_>
51 typedef typename StringSet::String
String;
66 size_t size()
const {
return active_.size(); }
70 assert(offset + sub_size <=
size());
71 return StringPtr(active_.subi(offset, offset + sub_size));
78 template <
typename LcpType>
79 void set_lcp(
size_t ,
const LcpType& )
const { }
82 template <
typename LcpType>
89 WithShadow
add_shadow(
const StringSet& shadow)
const;
96 template <
typename StringSet_,
typename LcpType_>
102 typedef typename StringSet::String
String;
114 : active_(ss), lcp_(lcp) { }
120 size_t size()
const {
return active_.size(); }
124 assert(offset + sub_size <=
size());
125 return StringLcpPtr(active_.subi(offset, offset + sub_size),
144 void set_lcp(
size_t i,
const LcpType& v)
const {
151 for (
size_t i = 1; i <
size(); ++i)
159 WithShadow
add_shadow(
const StringSet& shadow)
const;
167 template <
typename StringSet_>
172 typedef typename StringSet::String
String;
185 bool flipped =
false)
186 : active_(original), shadow_(shadow), flipped_(flipped) { }
192 const StringSet&
shadow()
const {
return shadow_; }
198 size_t size()
const {
return active_.size(); }
202 assert(offset + sub_size <=
size());
204 shadow_.subi(offset, offset + sub_size),
211 assert(offset + sub_size <=
size());
213 active_.subi(offset, offset + sub_size),
224 std::move(active_.begin(), active_.end(), shadow_.begin());
233 template <
typename LcpType>
234 void set_lcp(
size_t ,
const LcpType& )
const { }
237 template <
typename LcpType>
246 template <
typename StringSet_,
typename LcpType_>
252 typedef typename StringSet::String
String;
268 LcpType* lcp,
bool flipped =
false)
269 : active_(original), shadow_(shadow), lcp_(lcp), flipped_(flipped) { }
275 const StringSet&
shadow()
const {
return shadow_; }
281 size_t size()
const {
return active_.size(); }
285 assert(offset + sub_size <=
size());
287 shadow_.subi(offset, offset + sub_size),
288 lcp_ + offset, flipped_);
294 assert(offset + sub_size <=
size());
296 active_.subi(offset, offset + sub_size),
297 lcp_ + offset, !flipped_);
307 std::move(active_.begin(), active_.end(), shadow_.begin());
327 void set_lcp(
size_t i,
const LcpType& v)
const {
334 for (
size_t i = 1; i <
size(); ++i)
341 template <
typename StringSet_>
347 template <
typename StringSet_,
typename LcpType_>
361 #endif // !TLX_SORT_STRINGS_STRING_PTR_HEADER StringLcpPtr(const StringSet &ss, LcpType *lcp)
constructor specifying all attributes
void set_lcp(size_t i, const LcpType &v) const
set the i-th lcp to v and check its value
Objectified string array pointer and shadow pointer array for out-of-place swapping of pointers...
StringPtr sub(size_t offset, size_t sub_size) const
Advance (both) pointers by given offset, return sub-array.
LcpType * lcp() const
return LCP array pointer
size_t size() const
return valid length
StringShadowLcpPtr flip(size_t offset, size_t sub_size) const
construct a StringShadowLcpPtr object specifying a sub-array with flipping to other array...
size_t size() const
return valid length
StringShadowPtr sub(size_t offset, size_t sub_size) const
Advance (both) pointers by given offset, return sub-array without flip.
const StringSet & active() const
return currently active array
void set_lcp(size_t, const LcpType &) const
set the i-th lcp to v and check its value
void fill_lcp(const LcpType &) const
fill entire LCP array with v, excluding the first lcp[0] position!
StringSet::Iterator Iterator
StringShadowLcpPtr sub(size_t offset, size_t sub_size) const
Advance (both) pointers by given offset, return sub-array without flip.
StringShadowPtr copy_back() const
return subarray pointer to n strings in original array, might copy from shadow before returning...
const StringSet & active() const
return currently active array
StringSet active_
strings (front) array
StringShadowPtr(const StringSet &original, const StringSet &shadow, bool flipped=false)
constructor specifying all attributes
LcpType get_lcp(size_t i) const
return LCP array value
StringLcpPtr sub(size_t offset, size_t sub_size) const
Advance (both) pointers by given offset, return sub-array.
size_t size() const
return valid length
void set_lcp(size_t i, const LcpType &v) const
set the i-th lcp to v and check its value
const StringSet & active() const
return currently active array
void fill_lcp(const LcpType &) const
fill entire LCP array with v, excluding the first lcp[0] position!
StringShadowPtr< StringSet_ > WithShadow
objectified string and shadow pointer class
void set_lcp(size_t, const LcpType &) const
set the i-th lcp to v and check its value
bool flipped() const
true if flipped to back array
size_t size() const
return valid length
bool flipped_
false if active_ is original, true if shadow_ is original
static const bool with_lcp
if we want to save the LCPs
void fill_lcp(const LcpType &v) const
fill entire LCP array with v, excluding the first lcp[0] position!
const StringSet & shadow() const
return current shadow array
WithShadow add_shadow(const StringSet &shadow) const
construct objectified string and shadow pointer class
bool flipped_
false if active_ is original, true if shadow_ is original
WithShadow add_shadow(const StringSet &shadow) const
construct objectified string and shadow pointer class
Objectified string and LCP array pointer arrays.
StringSet active_
strings (front) array
const StringSet & active() const
return currently active array
StringShadowLcpPtr< StringSet_, LcpType_ > WithShadow
objectified string and shadow pointer class
bool flipped() const
true if flipped to back array
StringShadowLcpPtr copy_back() const
return subarray pointer to n strings in original array, might copy from shadow before returning...
Objectified string array pointer and shadow pointer array for out-of-place swapping of pointers...
StringShadowPtr flip(size_t offset, size_t sub_size) const
construct a StringShadowPtr object specifying a sub-array with flipping to other array.
StringPtr(const StringSet &ss)
constructor specifying all attributes
StringSet::Iterator Iterator
void fill_lcp(const LcpType &v) const
fill entire LCP array with v, excluding the first lcp[0] position!
LcpType * lcp() const
return LCP array pointer
const StringSet & shadow() const
return current shadow array
Objectified string array pointer array.
LcpType get_lcp(size_t i) const
return LCP array value
StringShadowLcpPtr(const StringSet &original, const StringSet &shadow, LcpType *lcp, bool flipped=false)
constructor specifying all attributes