<commit_before>/******************************************************************************
 * This file is part of dirtsand.                                             *
 *                                                                            *
 * dirtsand is free software: you can redistribute it and/or modify           *
 * it under the terms of the GNU Affero General Public License as             *
 * published by the Free Software Foundation, either version 3 of the         *
 * License, or (at your option) any later version.                            *
 *                                                                            *
 * dirtsand is distributed in the hope that it will be useful,                *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU Affero General Public License for more details.                        *
 *                                                                            *
 * You should have received a copy of the GNU Affero General Public License   *
 * along with dirtsand.  If not, see <http://www.gnu.org/licenses/>.          *
 ******************************************************************************/

#ifndef _DS_BITVECTOR_H
#define _DS_BITVECTOR_H

#include "streams.h"

namespace DS
{
    class BitVector
    {
    public:
        BitVector() : m_bits(), m_words() { }

        BitVector(const BitVector& copy) : m_words(copy.m_words)
        {
            m_bits = new uint32_t[m_words];
            memcpy(m_bits, copy.m_bits, m_words);
        }

        BitVector(const BitVector&& move)
            : m_bits(move.m_bits), m_words(move.m_words) { }

        ~BitVector() { delete[] m_bits; }

        bool get(size_t idx) const
        {
            return (m_words < (idx / 32)) ? false
                 : (m_bits[idx / 32] & (1 << (idx % 32))) != 0;
        }

        void set(size_t idx, bool bit);

        BitVector& operator=(const BitVector& copy)
        {
            delete[] m_bits;
            m_words = copy.m_words;
            m_bits = new uint32_t[m_words];
            memcpy(m_bits, copy.m_bits, m_words);
            return *this;
        }

        BitVector& operator=(const BitVector&& move)
        {
            delete[] m_bits;
            m_bits = move.m_bits;
            m_words = move.m_words;
            return *this;
        }

        void read(DS::Stream* stream);<commit_msg>Don't let BitVector moves cause duplicate deletions<commit_after>/******************************************************************************
 * This file is part of dirtsand.                                             *
 *                                                                            *
 * dirtsand is free software: you can redistribute it and/or modify           *
 * it under the terms of the GNU Affero General Public License as             *
 * published by the Free Software Foundation, either version 3 of the         *
 * License, or (at your option) any later version.                            *
 *                                                                            *
 * dirtsand is distributed in the hope that it will be useful,                *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU Affero General Public License for more details.                        *
 *                                                                            *
 * You should have received a copy of the GNU Affero General Public License   *
 * along with dirtsand.  If not, see <http://www.gnu.org/licenses/>.          *
 ******************************************************************************/

#ifndef _DS_BITVECTOR_H
#define _DS_BITVECTOR_H

#include "streams.h"

namespace DS
{
    class BitVector
    {
    public:
        BitVector() : m_bits(), m_words() { }

        BitVector(const BitVector& copy) : m_words(copy.m_words)
        {
            m_bits = new uint32_t[m_words];
            memcpy(m_bits, copy.m_bits, m_words);
        }

        BitVector(BitVector&& move)
            : m_bits(move.m_bits), m_words(move.m_words)
        {
            move.m_bits = nullptr;
        }

        ~BitVector() { delete[] m_bits; }

        bool get(size_t idx) const
        {
            return (m_words < (idx / 32)) ? false
                 : (m_bits[idx / 32] & (1 << (idx % 32))) != 0;
        }

        void set(size_t idx, bool bit);

        BitVector& operator=(const BitVector& copy)
        {
            delete[] m_bits;
            m_words = copy.m_words;
            m_bits = new uint32_t[m_words];
            memcpy(m_bits, copy.m_bits, m_words);
            return *this;
        }

        BitVector& operator=(BitVector&& move)
        {
            delete[] m_bits;
            m_bits = move.m_bits;
            m_words = move.m_words;
            move.m_bits = nullptr;
            return *this;
        }

        void read(DS::Stream* stream);
{'fraction_non_alphanumeric': 0.13954846243674582, 'fraction_numerical': 0.00506033476060724, 'mean_word_length': 1.4436519258202567, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4072178', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1246, 'n_words': 385}