NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Methods | Related Functions | List of all members
nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator > Struct Template Reference

Detailed description

template< typename StringIterator, typename OffsetIterator>
struct nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >

A "flat" collection of strings that are concatenated together into a single one, and their starting points are given by a single offset vector.

Here's an example defining a simple concatenated string set:

// pack a few strings into a concatenated buffer
const uint32 n_strings = 3;
const char* strings = { "abc", "defghi", "lmno" };
thrust::host_vector<uint32> offsets_storage( n_strings+1 );
thrust::host_vector<char> string_storage( strlen( strings[0] ) +
strlen( strings[1] ) +
strlen( strings[2] ) );
typedef ConcatenatedStringSet<char*, uint32*> string_set_type;
// build the string set
string_set_type string_set(
n_strings,
char*,
plain_view( offsets_storage ) );
// setup the offsets, note we need to place a sentinel
offsets_storage[0] = 0;
for (uint32 i = 0; i < n_reads; ++i)
offsets_storage[i+1] += strlen( strings[i] );
// and now we can conveniently access the i-th string of the set
for (uint32 i = 0; i < n_reads; ++i)
{
string_set_type::string_type string = string_set[i];
// and fill them in
for (uint32 j = 0; j < string.length(); ++j)
string[j] = strings[i][j];
}

or even a packed one:

// pack 1000 x 100bp reads into a single concatenated buffer
const uint32 n_reads = 1000;
const uint32 read_len = 100;
const uint32 n_words = util::divide_ri( n_reads * read_len * 2, 32 ); // we can fit 16 bps in each word
thrust::host_vector<uint32> offsets_storage( n_reads+1 );
thrust::host_vector<uint32> string_storage( n_words );
typedef PackedStream<uint32*, uint8, 2u, false> packed_stream_type;
typedef uint32* offsets_iterator;
typedef ConcatenatedStringSet<packed_stream_type, offsets_iterator> packed_string_set;
packed_stream_type packed_stream( plain_view( string_storage ) );
// build the string set
packed_string_set string_set(
n_reads,
packed_stream,
plain_view( offsets_storage ) );
// setup the offsets, note we need to place a sentinel
for (uint32 i = 0; i < n_reads+1; ++i)
offsets_storage[i] = i * read_len;
// and now we can conveniently access the i-th string of the set
for (uint32 i = 0; i < n_reads; ++i)
{
packed_string_set::string_type string = string_set[i];
// and fill them in
for (uint32 j = 0; j < string.length(); ++j)
string[j] = ...
}

Definition at line 480 of file string_set.h.

#include <string_set.h>

Public Types

typedef concatenated_string_set_tag string_set_tag
 
typedef std::iterator_traits
< StringIterator >::value_type 
symbol_type
 
typedef vector_view
< StringIterator > 
string_type
 
typedef StringIterator symbol_iterator
 
typedef OffsetIterator offset_iterator
 
typedef iterator_system
< StringIterator >::type 
system_tag
 
typedef StringSetIterator
< ConcatenatedStringSet
< StringIterator,
OffsetIterator > > 
iterator
 
typedef StringSetIterator
< ConcatenatedStringSet
< StringIterator,
OffsetIterator > > 
const_iterator
 

Public Methods

NVBIO_FORCEINLINE NVBIO_HOST_DEVICE ConcatenatedStringSet ()
 
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE ConcatenatedStringSet (const uint32 size, const StringIterator string, const OffsetIterator offsets)
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE uint32 
size () const
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE string_type 
operator[] (const uint32 i) const
 
const_iterator begin () const
 
const_iterator end () const
 
iterator begin ()
 
iterator end ()
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
symbol_iterator 
base_string () const
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
offset_iterator 
offsets () const
 

Related Functions

(Note that these are not member functions.)

template<typename StringIterator , typename OffsetIterator >
ConcatenatedStringSet
< StringIterator,
OffsetIterator > 
make_concatenated_string_set (const uint32 size, const StringIterator string, const OffsetIterator offsets)
 

Member Typedef Documentation

template<typename StringIterator, typename OffsetIterator>
typedef StringSetIterator< ConcatenatedStringSet<StringIterator,OffsetIterator> > nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::const_iterator

Definition at line 490 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef StringSetIterator< ConcatenatedStringSet<StringIterator,OffsetIterator> > nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::iterator

Definition at line 489 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef OffsetIterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::offset_iterator

Definition at line 486 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef concatenated_string_set_tag nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::string_set_tag

Definition at line 482 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef vector_view<StringIterator> nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::string_type

Definition at line 484 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef StringIterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::symbol_iterator

Definition at line 485 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef std::iterator_traits<StringIterator>::value_type nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::symbol_type

Definition at line 483 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
typedef iterator_system<StringIterator>::type nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::system_tag

Definition at line 487 of file string_set.h.

Constructor & Destructor Documentation

template<typename StringIterator, typename OffsetIterator>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::ConcatenatedStringSet ( )
inline

default constructor

Definition at line 495 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::ConcatenatedStringSet ( const uint32  size,
const StringIterator  string,
const OffsetIterator  offsets 
)
inline

constructor

Parameters
sizeset size
stringflat string iterator
offsetsstring offsets in the flat string array, must contain size+1 entries

Definition at line 504 of file string_set.h.

Member Function Documentation

template<typename StringIterator, typename OffsetIterator>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE symbol_iterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::base_string ( ) const
inline

return the base string

Definition at line 548 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
const_iterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::begin ( void  ) const
inline

begin iterator

Definition at line 531 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
iterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::begin ( void  )
inline

begin iterator

Definition at line 539 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
const_iterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::end ( void  ) const
inline

begin iterator

Definition at line 535 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
iterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::end ( void  )
inline

begin iterator

Definition at line 543 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE offset_iterator nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::offsets ( ) const
inline

return the offset vector

Definition at line 553 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE string_type nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::operator[] ( const uint32  i) const
inline

indexing operator: access the i-th string

Definition at line 520 of file string_set.h.

template<typename StringIterator, typename OffsetIterator>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE uint32 nvbio::ConcatenatedStringSet< StringIterator, OffsetIterator >::size ( void  ) const
inline

set size

Definition at line 515 of file string_set.h.


The documentation for this struct was generated from the following file: