void bps(uint64_t node, writer_type & bitout) const { bitout.writeBit(1); if ( CartesianTree<key_type>::getLeft(node) != CartesianTree<key_type>::n ) bps(CartesianTree<key_type>::getLeft(node),bitout); if ( CartesianTree<key_type>::getRight(node) != CartesianTree<key_type>::n ) bps(CartesianTree<key_type>::getRight(node),bitout); bitout.writeBit(0); }
XalanIndentWriter( writer_type& writer, size_type ident) : m_whiteSpaceWriter(writer), m_newLineWriter(writer), m_indent(ident), m_currentIndent(0), m_startNewLine(false), m_ispreserve(false), m_isprevtext(false), m_preserves(writer.getMemoryManager(), 5) { assert( m_indent != -1); }
static void writeIndex( writer_type & writer, std::vector < IndexEntry > const & index, uint64_t const indexpos, uint64_t const numsyms) { uint64_t const maxpos = index.size() ? index[index.size()-1].pos : 0; unsigned int const posbits = ::libmaus2::math::bitsPerNum(maxpos); uint64_t const kacc = std::accumulate(index.begin(),index.end(),0ull,IndexEntryKeyAdd()); unsigned int const kbits = ::libmaus2::math::bitsPerNum(kacc); uint64_t const vacc = std::accumulate(index.begin(),index.end(),0ull,IndexEntryValueAdd()); unsigned int const vbits = ::libmaus2::math::bitsPerNum(vacc); // index size (number of blocks) writer.writeElias2(index.size()); // write number of bits per file position writer.writeElias2(posbits); // write vbits writer.writeElias2(kbits); // write vacc writer.writeElias2(kacc); // write vbits writer.writeElias2(vbits); // write vacc writer.writeElias2(vacc); // align writer.flushBitStream(); uint64_t tkacc = 0, tvacc = 0; // write index for ( uint64_t i = 0; i < index.size(); ++i ) { writer.write(index[i].pos,posbits); writer.write(tkacc,kbits); tkacc += index[i].kcnt; writer.write(tvacc,vbits); tvacc += index[i].vcnt; } writer.write(0,posbits); writer.write(tkacc,kbits); writer.write(tvacc,vbits); writer.flushBitStream(); assert ( numsyms == vacc ); for ( uint64_t i = 0; i < 64; ++i ) writer.writeBit( (indexpos & (1ull<<(63-i))) != 0 ); writer.flushBitStream(); }