<commit_before>#ifndef CLOTHO_BIT_WALKER_HPP_
#define CLOTHO_BIT_WALKER_HPP_

#include <iostream>
#include <cassert>
#include "clotho/utility/set_bit_node.h"

namespace clotho {
namespace utility {

template < unsigned int B >
class bit_block_walker {
public:
    typedef size_t              walkable_block_type;
    static const unsigned int   bits_per_block = B;

    template < class OP >
    void operator()( walkable_block_type _bits, OP & oper, unsigned int offset = 0 ) {
        if( !_bits ) return;

        unsigned int i = B, j = offset;
        while( i-- ) {
            if( _bits & 1 ) {
                oper( j );
            }
            _bits >>= 1;
            ++j;
        }
    }
};

template < >
class bit_block_walker< 8 > {
public:
    typedef unsigned char walkable_block_type;
    static const unsigned int bits_per_block = 8;
    static const unsigned int max_nodes = 256;  // 2^8

    static set_bit_node (&getNode())[ max_nodes ] {
        static bool i = node_array_initializer::init_array( m_nodes, max_nodes );
        return m_nodes;
    }

    template < class OP >
    void operator()( walkable_block_type _bits, OP & oper, unsigned int offset = 0 ) {
        if( !_bits ) return;

        set_bit_node * v = getNode() + _bits;
        do {
            oper( offset + v->bit_index );
            if( v->next == 0 ) break;

            offset += v->bit_shift_next;
            v = getNode() + v->next;
        } while( true );
    }
protected:
    static set_bit_node m_nodes[ max_nodes ];
};

set_bit_node bit_block_walker< 8 >::m_nodes[ bit_block_walker< 8 >::max_nodes ];

template < >
class bit_block_walker< 16 > {
public:
    typedef unsigned short walkable_block_type;
    static const unsigned int bits_per_block = 16;
    static const unsigned int max_nodes = 256 * 256;    // 2^16

    static set_bit_node (&getNode())[ max_nodes ] {
        static bool i = node_array_initializer::init_array(m_nodes, max_nodes);
        return m_nodes;
    }<commit_msg>Cleaned up unused variable warning. Will reappear if NDEBUG is disabled<commit_after>#ifndef CLOTHO_BIT_WALKER_HPP_
#define CLOTHO_BIT_WALKER_HPP_

#include <iostream>
#include <cassert>
#include "clotho/utility/set_bit_node.h"

namespace clotho {
namespace utility {

template < unsigned int B >
class bit_block_walker {
public:
    typedef size_t              walkable_block_type;
    static const unsigned int   bits_per_block = B;

    template < class OP >
    void operator()( walkable_block_type _bits, OP & oper, unsigned int offset = 0 ) {
        if( !_bits ) return;

        unsigned int i = B, j = offset;
        while( i-- ) {
            if( _bits & 1 ) {
                oper( j );
            }
            _bits >>= 1;
            ++j;
        }
    }
};

template < >
class bit_block_walker< 8 > {
public:
    typedef unsigned char walkable_block_type;
    static const unsigned int bits_per_block = 8;
    static const unsigned int max_nodes = 256;  // 2^8

    static set_bit_node (&getNode())[ max_nodes ] {
        static bool i = node_array_initializer::init_array( m_nodes, max_nodes );
        assert( i );
        return m_nodes;
    }

    template < class OP >
    void operator()( walkable_block_type _bits, OP & oper, unsigned int offset = 0 ) {
        if( !_bits ) return;

        set_bit_node * v = getNode() + _bits;
        do {
            oper( offset + v->bit_index );
            if( v->next == 0 ) break;

            offset += v->bit_shift_next;
            v = getNode() + v->next;
        } while( true );
    }
protected:
    static set_bit_node m_nodes[ max_nodes ];
};

set_bit_node bit_block_walker< 8 >::m_nodes[ bit_block_walker< 8 >::max_nodes ];

template < >
class bit_block_walker< 16 > {
public:
    typedef unsigned short walkable_block_type;
    static const unsigned int bits_per_block = 16;
    static const unsigned int max_nodes = 256 * 256;    // 2^16

    static set_bit_node (&getNode())[ max_nodes ] {
        static bool i = node_array_initializer::init_array(m_nodes, max_nodes);
        assert( i );
        return m_nodes;
    }
{'fraction_non_alphanumeric': 0.09980478282088824, 'fraction_numerical': 0.013177159590043924, 'mean_word_length': 2.438758389261745, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2540569', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1299, 'n_words': 368}