<commit_before>// $Id: stringHashMap.h,v 1.13 2001/06/22 10:51:31 oliver Exp $

#ifndef BALL_DATATYPE_STRINGHASHMAP_H
#define BALL_DATATYPE_STRINGHASHMAP_H

#ifndef BALL_COMMON_H
#	include <BALL/common.h>
#endif

#ifndef BALL_COMMON_HASH_H
#	include <BALL/COMMON/hash.h>
#endif

#ifndef BALL_CONCEPT_VISITOR_H
#	include <BALL/CONCEPT/visitor.h>
#endif

#ifndef BALL_CONCEPT_PROCESSOR_H
#	include <BALL/CONCEPT/processor.h>
#endif

#ifndef BALL_DATATYPE_HASHMAP_H
#	include <BALL/DATATYPE/hashMap.h>
#endif

#include <algorithm>

namespace BALL 
{

	template <class Value>
	class StringHashMap
		:	public HashMap<String, Value>
	{
		public:

		BALL_CREATE_DEEP(StringHashMap)

		/**	@name Type Definitions
		*/
		//@{

		/**	Iterator type
		*/
		typedef typename HashMap<String, Value>::Iterator Iterator;

		/**	Const iterator type
		*/
		typedef typename HashMap<String, Value>::ConstIterator ConstIterator;	
		
		/**	Value type
		*/
		typedef typename HashMap<String, Value>::ValueType ValueType;	
		//@}

		/**	@name	Constructors and Destructors */
		//@{

		/**	Default constructor.
				Create an empty hash map.
		*/
		StringHashMap()
			throw()
			: HashMap<String, Value>()
		{
		}

		/** Copy constructor.
				Create a copy of an existing hash map.
				@param	map the hash map to be copied
				@param	deep ignored
		*/
		StringHashMap(const StringHashMap& map, bool /* deep = true */)
			throw()
			: HashMap<String, Value>(map)
		{
		}
			
		/** Destructor.
				Destruct the hash map and free all used memory.
		*/
		virtual ~StringHashMap()
			throw()
		{
		}

		/** Clear the hash map.
				Remove all contents from the hash map.
		*/
		void destroy()
			throw()
		{
			clear();
		}
	
		//@}

		/**	@name	Assignment */
		//@{
			
		/** Assign a hash map from another.
				Create a copy of a hash map.
				@param	hash_map	the map to be copied
				@param	deep ignored
		*/
    void set(const StringHashMap& hash_map, bool /* deep */ = true)
			throw()
		{
			clear();

			ConstIterator it = hash_map.begin();
			for ( ; it != hash_map.end(); ++it)
			{
				insert(*it);
			}
		}

		/** Assign a hash map from another.
		*/
		const StringHashMap& operator = (const StringHashMap& hash_map)
			throw()
		{
			set(hash_map);
			return *this;
		}
			
		/// Assigns the content of a hash map to another
    void get(StringHashMap& hash_map, bool deep = true) const
			throw()
		{
			hash_map.set(*this, deep);
		}

		/// Swaps the contents of two hash maps
    void swap(StringHashMap& hash_map)
			throw()
		{
			std::swap(*this, hash_map);
		}

		//@}

		/**	@name Accessors */
		//@{

		/**	Insert a pair of key and value.
		*/
		std::pair<Iterator, bool> insert(const ValueType& obj)
			throw()
		{
			return HashMap<String, Value>::insert(obj);
		}
		
		/**	Insert a given value and key.
				@param	value the value to be inserted
				@param	key the value`s key
		*/
		std::pair<Iterator, bool> insert(const String& key, const Value& value)
			throw()
		{
			return HashMap<String, Value>::insert(typename HashMap<String, Value>::ValueType(key, value));
		}

			
		/**	Remove the entry {\tt key} from the map.
				@param	key the key of the entry to be removed
				@return	bool {\bf true} if the key was removed
		*/
		bool remove(const String& key)	
			throw()
		{
			// search the key
			Iterator it = find(key);
			if (it == end())
			{
				// we didn't find it..
				return false;
			}
			
			// found it: delete it
			erase(it);

			return true;
		}

		/** Return the size of the hash map.
		*/
		Size getSize() const
			throw()
		{
			return size();
		}
		
		/**	Return the load factor of the hash map.
				The load factor is defined as the quotient of
				the hash map size (the number of entries) and the number
				of buckets.
		*/
		float getLoadFactor() const
			throw()
		{
			return (float)size() / (float)HashMap<String, Value>::getBucketSize();
		}
	
		//@}

		/**	@name	Predicates */
		//@{

		/**	Compare two string hash maps.
		*/
		bool operator == (const StringHashMap<Value>& hash_map) const throw()
		{
			return HashMap<String, Value>::operator == (hash_map);
		}

		/**	Compare two string hash maps.
		*/
		bool operator != (const StringHashMap<Value>& hash_map) const throw()
		{
			return HashMap<String, Value>::operator != (hash_map);
		}

		/** Decide whether the hash map contains a given key.
		*/
		bool has(const String& key) const
			throw()
		{
			return !(find(key) == end());
		}

		/** Return true if the hash map is empty.
				This method return {\bf true} if the hash map does not contain any entries.
		*/
		bool isEmpty() const
			throw()
		{
			return (size() == 0);
		}
		//@}

		/**	@name	Miscellaneous */
		//@{

		/**	Visitor host method.
				StringHashMaps may be visited.
				@param	visitor	the visitor
		*/
		void host(Visitor<StringHashMap<Value> >& visitor)
			throw()
		{
			visitor.visit(*this);  
		}
		//@}

	};


}// namespace BALL

#endif // BALL_DATATYPE_HASHMAP_H
<commit_msg>fixed: s/class/typename, inserted missing :: before std<commit_after>// $Id: stringHashMap.h,v 1.14 2001/06/26 09:02:04 anker Exp $

#ifndef BALL_DATATYPE_STRINGHASHMAP_H
#define BALL_DATATYPE_STRINGHASHMAP_H

#ifndef BALL_COMMON_H
#	include <BALL/common.h>
#endif

#ifndef BALL_COMMON_HASH_H
#	include <BALL/COMMON/hash.h>
#endif

#ifndef BALL_CONCEPT_VISITOR_H
#	include <BALL/CONCEPT/visitor.h>
#endif

#ifndef BALL_CONCEPT_PROCESSOR_H
#	include <BALL/CONCEPT/processor.h>
#endif

#ifndef BALL_DATATYPE_HASHMAP_H
#	include <BALL/DATATYPE/hashMap.h>
#endif

#include <algorithm>

namespace BALL 
{

	template <typename Value>
	class StringHashMap
		:	public HashMap<String, Value>
	{
		public:

		BALL_CREATE_DEEP(StringHashMap)

		/**	@name Type Definitions
		*/
		//@{

		/**	Iterator type
		*/
		typedef typename HashMap<String, Value>::Iterator Iterator;

		/**	Const iterator type
		*/
		typedef typename HashMap<String, Value>::ConstIterator ConstIterator;	
		
		/**	Value type
		*/
		typedef typename HashMap<String, Value>::ValueType ValueType;	
		//@}

		/**	@name	Constructors and Destructors */
		//@{

		/**	Default constructor.
				Create an empty hash map.
		*/
		StringHashMap()
			throw()
			: HashMap<String, Value>()
		{
		}

		/** Copy constructor.
				Create a copy of an existing hash map.
				@param	map the hash map to be copied
				@param	deep ignored
		*/
		StringHashMap(const StringHashMap& map, bool /* deep = true */)
			throw()
			: HashMap<String, Value>(map)
		{
		}
			
		/** Destructor.
				Destruct the hash map and free all used memory.
		*/
		virtual ~StringHashMap()
			throw()
		{
		}

		/** Clear the hash map.
				Remove all contents from the hash map.
		*/
		void destroy()
			throw()
		{
			clear();
		}
	
		//@}

		/**	@name	Assignment */
		//@{
			
		/** Assign a hash map from another.
				Create a copy of a hash map.
				@param	hash_map	the map to be copied
				@param	deep ignored
		*/
    void set(const StringHashMap& hash_map, bool /* deep */ = true)
			throw()
		{
			clear();

			ConstIterator it = hash_map.begin();
			for ( ; it != hash_map.end(); ++it)
			{
				insert(*it);
			}
		}

		/** Assign a hash map from another.
		*/
		const StringHashMap& operator = (const StringHashMap& hash_map)
			throw()
		{
			set(hash_map);
			return *this;
		}
			
		/// Assigns the content of a hash map to another
    void get(StringHashMap& hash_map, bool deep = true) const
			throw()
		{
			hash_map.set(*this, deep);
		}

		/// Swaps the contents of two hash maps
    void swap(StringHashMap& hash_map)
			throw()
		{
			std::swap(*this, hash_map);
		}

		//@}

		/**	@name Accessors */
		//@{

		/**	Insert a pair of key and value.
		*/
		std::pair<Iterator, bool> insert(const ValueType& obj)
			throw()
		{
			return HashMap<String, Value>::insert(obj);
		}
		
		/**	Insert a given value and key.
				@param	value the value to be inserted
				@param	key the value`s key
		*/
		::std::pair<Iterator, bool> insert(const String& key, const Value& value)
			throw()
		{
			return HashMap<String, Value>::insert(typename HashMap<String, Value>::ValueType(key, value));
		}

			
		/**	Remove the entry {\tt key} from the map.
				@param	key the key of the entry to be removed
				@return	bool {\bf true} if the key was removed
		*/
		bool remove(const String& key)	
			throw()
		{
			// search the key
			Iterator it = find(key);
			if (it == end())
			{
				// we didn't find it..
				return false;
			}
			
			// found it: delete it
			erase(it);

			return true;
		}

		/** Return the size of the hash map.
		*/
		Size getSize() const
			throw()
		{
			return size();
		}
		
		/**	Return the load factor of the hash map.
				The load factor is defined as the quotient of
				the hash map size (the number of entries) and the number
				of buckets.
		*/
		float getLoadFactor() const
			throw()
		{
			return (float)size() / (float)HashMap<String, Value>::getBucketSize();
		}
	
		//@}

		/**	@name	Predicates */
		//@{

		/**	Compare two string hash maps.
		*/
		bool operator == (const StringHashMap<Value>& hash_map) const throw()
		{
			return HashMap<String, Value>::operator == (hash_map);
		}

		/**	Compare two string hash maps.
		*/
		bool operator != (const StringHashMap<Value>& hash_map) const throw()
		{
			return HashMap<String, Value>::operator != (hash_map);
		}

		/** Decide whether the hash map contains a given key.
		*/
		bool has(const String& key) const
			throw()
		{
			return !(find(key) == end());
		}

		/** Return true if the hash map is empty.
				This method return {\bf true} if the hash map does not contain any entries.
		*/
		bool isEmpty() const
			throw()
		{
			return (size() == 0);
		}
		//@}

		/**	@name	Miscellaneous */
		//@{

		/**	Visitor host method.
				StringHashMaps may be visited.
				@param	visitor	the visitor
		*/
		void host(Visitor<StringHashMap<Value> >& visitor)
			throw()
		{
			visitor.visit(*this);  
		}
		//@}

	};


}// namespace BALL

#endif // BALL_DATATYPE_HASHMAP_H

{'fraction_non_alphanumeric': 0.13293051359516617, 'fraction_numerical': 0.0036253776435045317, 'mean_word_length': 2.7014535967200897, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, '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': '6630215', 'n_tokens_mistral': 4066, 'n_tokens_neox': 3399, 'n_words': 1001}