Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
strings::utils::SequenceHelper< T > Class Template Reference

#include <sequence_helper.h>

List of all members.

Public Member Functions

 SequenceHelper (T *base_, int length_)
SequenceHelper reversed () const
SequenceHelper subsequence (int start_, int end_) const
int size () const
const T & operator[] (int pos) const
T & operator[] (int pos)

Private Member Functions

 SequenceHelper (T *base_, int start_, int length_)

Private Attributes

T * base
int start
int length

Detailed Description

template<typename T>
class strings::utils::SequenceHelper< T >

This is a simple helper class. It takes an pointer to the sequence array and can be used to access this array. Moreover, there are some handy functions like Creating subsequences from the original sequence or reversing the direction.

Note that SequenceHelper holds only pointers to the data, not the actual data itself. This means that you shouldn't deallocate the array itself if you have active instance of SequenceHelper you may edit the data and the changes will be reflected in SequenceHelper SequenceHelper is memory-cheap (no big arrays copying, can be on the stack


Constructor & Destructor Documentation

template<typename T>
strings::utils::SequenceHelper< T >::SequenceHelper ( T *  base_,
int  start_,
int  length_ 
) [inline, private]
template<typename T>
strings::utils::SequenceHelper< T >::SequenceHelper ( T *  base_,
int  length_ 
) [inline]

Construct the helper.

Parameters:
base_pointer to the start of the sequence (index 0)
length_length of the sequence

Member Function Documentation

template<typename T>
const T& strings::utils::SequenceHelper< T >::operator[] ( int  pos) const [inline]

[] operator like in arrays.

Parameters:
posindex of the element we want to retrieve.
template<typename T>
T& strings::utils::SequenceHelper< T >::operator[] ( int  pos) [inline]

[] operator like in arrays.

Parameters:
posindex of the element we want to retrieve.
template<typename T>
SequenceHelper strings::utils::SequenceHelper< T >::reversed ( ) const [inline]

Reverse SequenceHelper, i.e. the resulting object will satisfy new[0] = old[size - 1], ... , new[size - 1] = old[0]

Returns:
reversed SequenceHelper
template<typename T>
int strings::utils::SequenceHelper< T >::size ( ) const [inline]

Returns the size of the sequence

template<typename T>
SequenceHelper strings::utils::SequenceHelper< T >::subsequence ( int  start_,
int  end_ 
) const [inline]

Create subsequence of this sequence, i.e. the resulting object will be reindexed like this SequenceHelper([0, 1, 2, 3, 4, 5]).subsequence(2, 5) is equal to SequenceHelper([2, 3, 4])

The resulting subsequence will be representing elements [start_, end_) of the original sequence

Parameters:
start_starting index of the subsequence (will become zero in result)
end_index after the last position of the subsequence
Returns:
subsequence SequenceHelper

Member Data Documentation

template<typename T>
T* strings::utils::SequenceHelper< T >::base [private]
template<typename T>
int strings::utils::SequenceHelper< T >::length [private]
template<typename T>
int strings::utils::SequenceHelper< T >::start [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines