sstring.h
/**
	 * Reverse the 2-bit encoded DNA string in-place.
	 */
Reverse the 2-bit encoded DNA string in-place.
Reverse the 2 - bit encoded DNA string in - place .
void reverse() {
		if(len_ <= 1) return;
		size_t wordf = nwords()-1;
		size_t bpf   = (len_-1) & 15;
		size_t wordi = 0;
		size_t bpi   = 0;
		while(wordf > wordi || (wordf == wordi && bpf > bpi)) {
			int f = (cs_[wordf] >> (bpf << 1)) & 3;
			int i = (cs_[wordi] >> (bpi << 1)) & 3;
			cs_[wordf] &= ~(uint32_t)(3 << (bpf << 1));
			cs_[wordi] &= ~(uint32_t)(3 << (bpi << 1));
			cs_[wordf] |=  (uint32_t)(i << (bpf << 1));
			cs_[wordi] |=  (uint32_t)(f << (bpi << 1));
			if(bpf == 0) {
				bpf = 15;
				wordf--;
			} else bpf--;
			if(bpi == 15) {
				bpi = 0;
				wordi++;
			} else bpi++;
		}
	}
void reverse ( ) { if ( len_ <= 1 ) return ; size_t wordf = nwords ( ) - 1 ; size_t bpf = ( len_ - 1 ) & 15 ; size_t wordi = 0 ; size_t bpi = 0 ; while ( wordf > wordi || ( wordf == wordi && bpf > bpi ) ) { int f = ( cs_ [ wordf ] >> ( bpf << 1 ) ) & 3 ; int i = ( cs_ [ wordi ] >> ( bpi << 1 ) ) & 3 ; cs_ [ wordf ] &= ~ ( uint32_t ) ( 3 << ( bpf << 1 ) ) ; cs_ [ wordi ] &= ~ ( uint32_t ) ( 3 << ( bpi << 1 ) ) ; cs_ [ wordf ] |= ( uint32_t ) ( i << ( bpf << 1 ) ) ; cs_ [ wordi ] |= ( uint32_t ) ( f << ( bpi << 1 ) ) ; if ( bpf == 0 ) { bpf = 15 ; wordf -- ; } else bpf -- ; if ( bpi == 15 ) { bpi = 0 ; wordi ++ ; } else bpi ++ ; } }
Reverse the 2-bit encoded DNA string in-place.
Reverse the 2 - bit encoded DNA string in - place .