<commit_before>//
//  amici_vector.h

#include <vector>
#include <nvector/nvector_serial.h>

#ifndef amici_vector_h
#define amici_vector_h

namespace amici {
    
    /** AmiVector class.
     provides a generic interface to the NVector_Serial struct
     */
    class AmiVector {
    public:
        /** default constructor
         * creates an std::vector<realype> and attaches the 
         * data pointer to a newly created N_Vector_Serial
         * using N_VMake_Serial ensures that the N_Vector
         * module does not try to deallocate the data vector
         * when calling N_VDestroy_Serial
         * @param length number of elements in vector
         * @return new AmiVector instance
         */
        AmiVector(const long int length) : vec(length,0.0) {
            nvec = N_VMake_Serial(length,vec.data());
        };
        
        /** constructor from vector, copies data from vector
         * and constructs an nvec that points to the data
         * @param rvec vector from which the data will be copied
         * @return new AmiVector instance
         */
        AmiVector(std::vector<realtype> rvec) {
            vec = rvec;
            nvec = N_VMake_Serial(rvec.size(),rvec.data());
        };
        
        /** swap functions for copy-and-swap idiom, swaps data between two AmiVectors
         * see https://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom
         * @param first will be switched with second
         * @param second will be switched with first
         */
        friend void swap( AmiVector& first, AmiVector& second ) {
            std::swap(first.vec,second.vec);
            if(first.nvec)
                N_VDestroy_Serial(first.nvec);
            first.nvec = N_VMake_Serial(first.vec.size(),first.vec.data());
            if(second.nvec)
                N_VDestroy_Serial(second.nvec);
            second.nvec = N_VMake_Serial(second.vec.size(),second.vec.data());
        };
        
        /** copy constructor
         * @param vold vector from which the data will be copied
         */
        AmiVector(const AmiVector& vold) {
            vec = vold.vec;
            nvec = N_VMake_Serial(vold.vec.size(),vec.data());
        };
        
        /** copy-move assignment operator
         * @param other right hand side
         * @return left hand side
         */
        AmiVector& operator=(AmiVector& other) {
            vec = other.vec;
            if(nvec)
                N_VDestroy_Serial(nvec);<commit_msg>remove swap function (no longer used)<commit_after>//
//  amici_vector.h

#include <vector>
#include <nvector/nvector_serial.h>

#ifndef amici_vector_h
#define amici_vector_h

namespace amici {
    
    /** AmiVector class.
     provides a generic interface to the NVector_Serial struct
     */
    class AmiVector {
    public:
        /** default constructor
         * creates an std::vector<realype> and attaches the 
         * data pointer to a newly created N_Vector_Serial
         * using N_VMake_Serial ensures that the N_Vector
         * module does not try to deallocate the data vector
         * when calling N_VDestroy_Serial
         * @param length number of elements in vector
         * @return new AmiVector instance
         */
        AmiVector(const long int length) : vec(length,0.0) {
            nvec = N_VMake_Serial(length,vec.data());
        };
        
        /** constructor from vector, copies data from vector
         * and constructs an nvec that points to the data
         * @param rvec vector from which the data will be copied
         * @return new AmiVector instance
         */
        AmiVector(std::vector<realtype> rvec) {
            vec = rvec;
            nvec = N_VMake_Serial(rvec.size(),rvec.data());
        };
        
        /** copy constructor
         * @param vold vector from which the data will be copied
         */
        AmiVector(const AmiVector& vold) {
            vec = vold.vec;
            nvec = N_VMake_Serial(vold.vec.size(),vec.data());
        };
        
        /** copy-move assignment operator
         * @param other right hand side
         * @return left hand side
         */
        AmiVector& operator=(AmiVector& other) {
            vec = other.vec;
            if(nvec)
                N_VDestroy_Serial(nvec);
{'fraction_non_alphanumeric': 0.08861053119925771, 'fraction_numerical': 0.002551612154952447, 'mean_word_length': 1.9037037037037037, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '5734330', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1214, 'n_words': 346}