<commit_before>#ifndef ASSETMANAGER_H
#define ASSETMANAGER_H

#include <vector>
#include <memory>
#include <string>
#include <utility>
#include <algorithm>
#include <cassert>

template< class AssetType >
class AssetManager {
public:
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

template< >
class AssetManager< std::vector< double > > {
public:
    using AssetType = std::vector< double >;
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
    bool GetDataArray( std::string strId, std::shared_ptr< double > & data_array, int & size ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	int size_array = it_find->second.size();
	size = size_array;
	data_array = std::shared_ptr< double >( new double[ size_array ], std::default_delete<double[]>() );
	try {   
	    std::copy( it_find->second.begin(), it_find->second.end(), data_array.get() );
	}catch( ... ){
	    return false;
	}
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

template< >
class AssetManager< std::vector< int > > {
public:
    using AssetType = std::vector< int >;
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
    bool GetDataArray( std::string strId, std::shared_ptr< int > & data_array, int & size ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	int size_array = it_find->second.size();
	size = size_array;
	data_array = std::shared_ptr< int >( new int[ size_array ], std::default_delete<int[]>() );
	try {   
	    std::copy( it_find->second.begin(), it_find->second.end(), data_array.get() );
	}catch( ... ){
	    return false;
	}
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

#endif<commit_msg>Added AssetManager< vector< float > > specialization<commit_after>#ifndef ASSETMANAGER_H
#define ASSETMANAGER_H

#include <vector>
#include <memory>
#include <string>
#include <utility>
#include <algorithm>
#include <cassert>

template< class AssetType >
class AssetManager {
public:
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

template< >
class AssetManager< std::vector< double > > {
public:
    using AssetType = std::vector< double >;
    using ElementType = double;
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
    bool GetDataArray( std::string strId, std::shared_ptr< ElementType > & data_array, int & size ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	int size_array = it_find->second.size();
	size = size_array;
	data_array = std::shared_ptr< ElementType >( new ElementType[ size_array ], std::default_delete<double[]>() );
	try {   
	    std::copy( it_find->second.begin(), it_find->second.end(), data_array.get() );
	}catch( ... ){
	    return false;
	}
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

template< >
class AssetManager< std::vector< int > > {
public:
    using AssetType = std::vector< int >;
    using ElementType = int;
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
    bool GetDataArray( std::string strId, std::shared_ptr< ElementType > & data_array, int & size ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	int size_array = it_find->second.size();
	size = size_array;
	data_array = std::shared_ptr< ElementType >( new ElementType[ size_array ], std::default_delete<int[]>() );
	try {   
	    std::copy( it_find->second.begin(), it_find->second.end(), data_array.get() );
	}catch( ... ){
	    return false;
	}
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

template< >
class AssetManager< std::vector< float > > {
public:
    using AssetType = std::vector< float >;
    using ElementType = float;
    bool AddData( std::string strId, AssetType asset ){
	_MapAsset.emplace( strId, asset );
	return true;
    }
    bool GetData( std::string strId, AssetType & asset ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	asset = it_find->second;
	return true;
    }
    bool GetDataArray( std::string strId, std::shared_ptr< ElementType > & data_array, int & size ){
	auto it_find = _MapAsset.find( strId );
	if( _MapAsset.end() == it_find ){
	    return false;
	}
	int size_array = it_find->second.size();
	size = size_array;
	data_array = std::shared_ptr< ElementType >( new ElementType[ size_array ], std::default_delete<ElementType[]>() );
	try {   
	    std::copy( it_find->second.begin(), it_find->second.end(), data_array.get() );
	}catch( ... ){
	    return false;
	}
	return true;
    }
private:
    std::map< std::string, AssetType > _MapAsset;
};

#endif
{'fraction_non_alphanumeric': 0.14848390121913096, 'fraction_numerical': 0.0, 'mean_word_length': 3.811278195488722, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 83, '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': '7524223', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2228, 'n_words': 553}