<commit_before>/*
 *   CrissCross
 *   A multi-purpose cross-platform library.
 *
 *   A product of IO.IN Research.
 *
 *   (c) 2006-2009 <NAME>.
 *   Licensed under the New BSD License.
 *
 */

#ifndef __included_cc_stltree_h
#define __included_cc_stltree_h


/*
 * Something is wrong with Microsoft's and
 * Borland's std::map implementation.
 */
#ifdef ENABLE_STLTREE

#include <crisscross/deprecate.h>
#include <crisscross/compare.h>
#include <crisscross/node.h>
#include <crisscross/internal_mem.h>

#include <map>

namespace CrissCross
{
	namespace Data
	{
		/*! \brief An STL map wrapper. */
		/*!
		 *      This is a tree which does NOT allow duplicate keys.
		 */
		template <class Key, class Data>
		class STLTree
		{
			private:
				std::map<Key,Data,CrissCross::Data::LessThanComparator<Key> > m_map;

			public:

				/*! \brief The default constructor. */
				__forceinline STLTree() {};

				/*! \brief The destructor. */
				__forceinline ~STLTree() { empty(); };

				/*! \brief Empties the entire tree. */
				/*!
				 * \warning This won't free the memory occupied by the data, so the data must be freed
				 *    separately. The preferred way to do this is to serialize the data into a DArray
				 *    with ConvertToDArray() and then iterate through it to delete the data in whatever
				 *    way is proper.
				 */
				__forceinline void empty()
				{
					DArray<Key> *keys = ConvertIndexToDArray();
					m_map.clear();
					for (size_t i = 0; i < keys->size(); i++) {
						if (!keys->valid(i)) continue;
						Dealloc((*keys)[i]);
					}
				};

				/*! \brief Inserts data into the tree. */
				/*!<commit_msg>GCC 3.x: don't inline STLTree constructor or destructor<commit_after>/*
 *   CrissCross
 *   A multi-purpose cross-platform library.
 *
 *   A product of IO.IN Research.
 *
 *   (c) 2006-2009 <NAME>.
 *   Licensed under the New BSD License.
 *
 */

#ifndef __included_cc_stltree_h
#define __included_cc_stltree_h


/*
 * Something is wrong with Microsoft's and
 * Borland's std::map implementation.
 */
#ifdef ENABLE_STLTREE

#include <crisscross/deprecate.h>
#include <crisscross/compare.h>
#include <crisscross/node.h>
#include <crisscross/internal_mem.h>

#include <map>

namespace CrissCross
{
	namespace Data
	{
		/*! \brief An STL map wrapper. */
		/*!
		 *      This is a tree which does NOT allow duplicate keys.
		 */
		template <class Key, class Data>
		class STLTree
		{
			private:
				std::map<Key,Data,CrissCross::Data::LessThanComparator<Key> > m_map;

			public:

				/*! \brief The default constructor. */
				STLTree() {};

				/*! \brief The destructor. */
				~STLTree() { empty(); };

				/*! \brief Empties the entire tree. */
				/*!
				 * \warning This won't free the memory occupied by the data, so the data must be freed
				 *    separately. The preferred way to do this is to serialize the data into a DArray
				 *    with ConvertToDArray() and then iterate through it to delete the data in whatever
				 *    way is proper.
				 */
				__forceinline void empty()
				{
					DArray<Key> *keys = ConvertIndexToDArray();
					m_map.clear();
					for (size_t i = 0; i < keys->size(); i++) {
						if (!keys->valid(i)) continue;
						Dealloc((*keys)[i]);
					}
				};

				/*! \brief Inserts data into the tree. */
				/*!
{'fraction_non_alphanumeric': 0.12629336579427874, 'fraction_numerical': 0.005782105903834449, 'mean_word_length': 2.7225368063420157, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '3192094', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1052, 'n_words': 331}