<commit_before>#ifdef NL_DATA_CONTAINER_H_

#include "NL_DataContainer.h"

namespace NLE
{
	namespace Core
	{
		template<typename T>
		DataContainer<T>::DataContainer() :
			_sysId(-1),
			_dataPool(),
			_data(_dataPool),
			_updateQueue(),
			_distributor(nullptr)
		{
		}

		template<typename T>
		DataContainer<T>::~DataContainer()
		{
		}

		template<typename T>
		bool DataContainer<T>::initialize(uint_fast8_t sysId, uint_fast8_t initSize)
		{
			_sysId = sysId;
			_data.reserve(initSize);
			return true;
		}

		template<typename T>
		void DataContainer<T>::release()
		{
			_data.clear();
			_dataPool.recycle();
		}

		template<typename T>
		void DataContainer<T>::bindDistributor(DataDistributor<T>* distributor)
		{
			_distributor = distributor;
		}

		template<typename T>
		inline void add(T data)
		{
			_data.push_back(data);
		}

		template<typename T>
		void DataContainer<T>::remove(uint_fast8_t index)
		{
			uint_fast8_t size = _data.size();
			if (index < size)
			{
				uint_fast8_t lastOccupied = size - 1;
				if (index != lastOccupied)
				{
					_data[index] = _data[lastOccupied];
				}
				_data.pop_back();
			}
		}

		template<typename T>
		void DataContainer<T>::modify(uint_fast8_t index, T data)
		{
			_data[index] = data;
			if (_distributor)
			{
				_distributor->queue({ _sysId, index, data });
			}
		}

		template<typename T>
		inline void DataContainer<T>::clear()
		{
			_data.clear();
		}

		template<typename T>
		inline uint_fast8_t DataContainer<T>::size()
		{
			return _data.size();
		}

		template<typename T>
		inline T& DataContainer<T>::get(uint_fast8_t index)
		{
			return _data[index];
		}

		template<typename T>
		inline void DataContainer<T>::queuePacket(DataPacket<T> packet)
		{
			_updateQueue.push(packet);
		}

		template<typename T>
		void DataContainer<T>::applyUpdates()
		{
			DataPacket<T> packet;
			while (_updateQueue.try_pop(packet))
			{
				modify(packet.getItemNumber(), packet.getData());
			}
		}
	}
}

#endif<commit_msg>bug fix: applying container update distributes data<commit_after>#ifdef NL_DATA_CONTAINER_H_

#include "NL_DataContainer.h"

namespace NLE
{
	namespace Core
	{
		template<typename T>
		DataContainer<T>::DataContainer() :
			_sysId(-1),
			_dataPool(),
			_data(_dataPool),
			_updateQueue(),
			_distributor(nullptr)
		{
		}

		template<typename T>
		DataContainer<T>::~DataContainer()
		{
		}

		template<typename T>
		bool DataContainer<T>::initialize(uint_fast8_t sysId, uint_fast8_t initSize)
		{
			_sysId = sysId;
			_data.reserve(initSize);
			return true;
		}

		template<typename T>
		void DataContainer<T>::release()
		{
			_data.clear();
			_dataPool.recycle();
		}

		template<typename T>
		void DataContainer<T>::bindDistributor(DataDistributor<T>* distributor)
		{
			_distributor = distributor;
		}

		template<typename T>
		inline void add(T data)
		{
			_data.push_back(data);
		}

		template<typename T>
		void DataContainer<T>::remove(uint_fast8_t index)
		{
			uint_fast8_t size = _data.size();
			if (index < size)
			{
				uint_fast8_t lastOccupied = size - 1;
				if (index != lastOccupied)
				{
					_data[index] = _data[lastOccupied];
				}
				_data.pop_back();
			}
		}

		template<typename T>
		void DataContainer<T>::modify(uint_fast8_t index, T data)
		{
			_data[index] = data;
			if (_distributor)
			{
				_distributor->queue({ _sysId, index, data });
			}
		}

		template<typename T>
		inline void DataContainer<T>::clear()
		{
			_data.clear();
		}

		template<typename T>
		inline uint_fast8_t DataContainer<T>::size()
		{
			return _data.size();
		}

		template<typename T>
		inline T& DataContainer<T>::get(uint_fast8_t index)
		{
			return _data[index];
		}

		template<typename T>
		inline void DataContainer<T>::queuePacket(DataPacket<T> packet)
		{
			_updateQueue.push(packet);
		}

		template<typename T>
		void DataContainer<T>::applyUpdates()
		{
			DataPacket<T> packet;
			while (_updateQueue.try_pop(packet))
			{
				_data[packet.getItemNumber()] = packet.getData();
			}
		}
	}
}

#endif
{'fraction_non_alphanumeric': 0.13193069306930694, 'fraction_numerical': 0.0049504950495049506, 'mean_word_length': 3.6662817551963047, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, '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': '7462977', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1476, 'n_words': 257}