<commit_before>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2011 <NAME>
 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
 */

#ifndef __CSTRINGMAP_H_
#define __CSTRINGMAP_H_

#include <shogun/base/SGObject.h>

namespace shogun
{

class CStringMapElement : public CSGObject
{
public:
	CStringMapElement();

	CStringMapElement(const char* key, const char* value);

	virtual ~CStringMapElement();

	inline virtual const char* get_name() const { return "StringMapElement"; }

private:
	void init();

public:
	char* m_key;
	char* m_value;
};

template<class T> class CDynamicObjectArray;

class CStringMap : public CSGObject
{
public:
	CStringMap();

	virtual ~CStringMap();

	void put(const char* key, const char* value);
	const char* get(const char* key) const;

	inline virtual const char* get_name() const { return "StringMap"; }

protected:
	/** list of CStringMap elements, this is always kept sorted */<commit_msg>added documentation<commit_after>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2011 <NAME>
 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
 */

#ifndef __CSTRINGMAP_H_
#define __CSTRINGMAP_H_

#include <shogun/base/SGObject.h>

namespace shogun
{

/** @brief Implements key-value pairs that are put into a CStringMap
 * Note that strings are copied in constructor.
 */
class CStringMapElement : public CSGObject
{
public:
	/** constructor */
	CStringMapElement();

	/** constructor. Takes key and value string and stores a copy of it */
	CStringMapElement(const char* key, const char* value);

	/** destructor */
	virtual ~CStringMapElement();

	/** @return name of the SG_SERIALIZABLE */
	inline virtual const char* get_name() const { return "StringMapElement"; }

private:
	void init();

public:
	char* m_key;
	char* m_value;
};

template<class T> class CDynamicObjectArray;

/** @brief implements a simple map for c-strings.
 * Note that these are copied when put to the map. When getting an element,
 * these copies are returned.
 *
 * As for now the implemenation is simple: O(n) for get, O(1) for put.
 * This may be done by some kind of tree to get logarithmic costs.
 * Beware of putting large amounts of elements in this map! Slow.
 */
class CStringMap : public CSGObject
{
public:
	/** constructor */
	CStringMap();

	/** destructor */
	virtual ~CStringMap();

	/** puts a key-value pair into the map
	 *
	 * @param key key of the element
	 * @param value value of the element
	 */
	void put(const char* key, const char* value);

	/** gets a value of a provided key
	 *
	 * @param key key of the element to get
	 * @return value of the specified key, NULL if there is no such
	 */
	const char* get(const char* key) const;

	/** @return name of the SG_SERIALIZABLE */
	inline virtual const char* get_name() const { return "StringMap"; }

protected:
	/** list of CStringMap elements, this is always kept sorted */
{'fraction_non_alphanumeric': 0.09560800717060054, 'fraction_numerical': 0.005676725425754407, 'mean_word_length': 4.072727272727272, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7558763', 'n_tokens_mistral': 1037, 'n_tokens_neox': 990, 'n_words': 424}