hi
What is the best way to get reverse of QString and QByteArray (fast and safe) with out using loops (it becomes very slow with huge data)
thanks
Br
Sis
hi
What is the best way to get reverse of QString and QByteArray (fast and safe) with out using loops (it becomes very slow with huge data)
thanks
Br
Sis
If you don't want to maintain loops, then may be you can maintain a copy of reverse. I mean a parallel copy. Each time you do an append on the string, do the similar reversed operation of the other copy. Tricky
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
alrawab (12th January 2013)
yes it a good idea but i'm dealing with dna sequences .
i'm using :
for( QByteArray::const_iterator i = myqbyte.constEnd(); i !=myqbyte.constBegin(); )
but this procedure become so slow with large sequences
DNA
I were to do so, I would write a customized container for DNA strand/sequence, (This will need knowledge of DNA structure and ways to digitize it)
There are other methods, but are applciation specific, like reverse only the section of the sequence? (instead of complete sequence).
Think again do you really want to reverse the sequence? can you not re-write your operation to operate on the sequence in reverse (I bet that should be acceptable)
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
this is my function which do the reverse task (some time i need to get the reverse of the full length )
//--------------------------------------
// Returns the reverse strand of a DNA or RNA sequence.
QByteArray QDnaSequence::Reverse(QByteArray& seq)
{
QByteArray reverse;
for( QByteArray::const_iterator i = seq.constEnd(); i !=seq.constBegin(); )
{
--i;
reverse += *i;
}
return reverse;
}
Bookmarks