Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
|
#include <sequence_helper.h>
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 |
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
strings::utils::SequenceHelper< T >::SequenceHelper | ( | T * | base_, |
int | start_, | ||
int | length_ | ||
) | [inline, private] |
strings::utils::SequenceHelper< T >::SequenceHelper | ( | T * | base_, |
int | length_ | ||
) | [inline] |
Construct the helper.
base_ | pointer to the start of the sequence (index 0) |
length_ | length of the sequence |
const T& strings::utils::SequenceHelper< T >::operator[] | ( | int | pos | ) | const [inline] |
[] operator like in arrays.
pos | index of the element we want to retrieve. |
T& strings::utils::SequenceHelper< T >::operator[] | ( | int | pos | ) | [inline] |
[] operator like in arrays.
pos | index of the element we want to retrieve. |
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]
int strings::utils::SequenceHelper< T >::size | ( | ) | const [inline] |
Returns the size of the sequence
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
start_ | starting index of the subsequence (will become zero in result) |
end_ | index after the last position of the subsequence |
T* strings::utils::SequenceHelper< T >::base [private] |
int strings::utils::SequenceHelper< T >::length [private] |
int strings::utils::SequenceHelper< T >::start [private] |