HashMap.hpp #1

  • //
  • guest/
  • ququlala/
  • libsprawl/
  • mainline/
  • collections/
  • HashMap.hpp
  • View
  • Commits
  • Open Download .zip Download (2 KB)
#pragma once

#include "hashmap/HashMap_Variadic.hpp"

namespace sprawl
{
	namespace collections
	{
		template<typename ValueType>
		using HashSet = HashMap<ValueType, SelfAccessor<ValueType>>;

		template<typename KeyType, typename ValueType>
		using BasicHashMap = HashMap<ValueType, KeyAccessor<ValueType, KeyType>>;

		template<typename KeyType, typename ValueType, KeyType(ValueType::*function)()>
		using MemberHashMap = HashMap<ValueType, MemberAccessor<ValueType, KeyType, function>>;

		template<typename KeyType, typename ValueType, KeyType(ValueType::*function)() const>
		using ConstMemberHashMap = HashMap<ValueType, ConstMemberAccessor<ValueType, KeyType, function>>;

		namespace detail
		{
			template<typename T>
			struct UnderlyingType
			{
				typedef typename std::remove_reference<decltype(*(std::declval<T>()))>::type type;
			};

			template<typename KeyType, typename ValueType>
			struct MethodType
			{
				typedef typename UnderlyingType<ValueType>::type UType;
				typedef KeyType(UType::*type)(void);
				typedef KeyType(UType::*const_type)(void) const;
			};
		}

		template<typename KeyType, typename ValueType, typename detail::MethodType<KeyType, ValueType>::type function>
		using PtrMemberHashMap = HashMap<ValueType, PtrMemberAccessor<typename detail::UnderlyingType<ValueType>::type, KeyType, function, ValueType>>;

		template<typename KeyType, typename ValueType, typename detail::MethodType<KeyType, ValueType>::const_type function>
		using PtrConstMemberHashMap = HashMap<ValueType, PtrConstMemberAccessor<typename detail::UnderlyingType<ValueType>::type, KeyType, function, ValueType>>;

		template<typename KeyType, typename ValueType, KeyType(*function)(ValueType*)>
		using FunctionHashMap = HashMap<ValueType, FunctionAccessor<ValueType, KeyType, function>>;

		template<typename KeyType, typename ValueType, KeyType(*function)(typename detail::UnderlyingType<ValueType>::type*)>
		using PtrFunctionHashMap = HashMap<ValueType, PtrFunctionAccessor<typename detail::UnderlyingType<ValueType>::type, KeyType, function, ValueType>>;
	}
}
# Change User Description Committed
#1 23398 ququlala "Forking branch Mainline of shadauxcat-libsprawl to ququlala-libsprawl."
//guest/ShadauxCat/Sprawl/Mainline/collections/HashMap.hpp
#5 14220 ShadauxCat -Added binary tree implementation (red/black tree) with same multi-key interface as hashmap
-Renamed AccessorGroup to MapAccessorGroup to make room for TreeAccessorGroup, which is a lot of duplicated code but had to meet some specific requirements that couldn't be easily fit into the existing AccessorGroup
-Fixed HashMap::Clear() not resetting size to 0
-Fixed HashMap::Erase() neither decrementing size nor freeing memory
-Changed HashMap to grow before insert instead of after (delaying needed growth until the next insert instead of growing when it detects the next insert will need it)
-Fixed a style issue for private function HashMap_Impl::insertHere_()
-Fully removed support for Visual Studio 2012 as I have neither the need nor the desire to continue supporting it. The doubled maintenance cost is too high.
-Included array unit test that got missed before

#review-14221
#4 14121 ShadauxCat -Fixed msvc compile errors (msvc sucks at decltype, btw...)
-Fixed BitVector and BitSet being broken on msvc due to 1L being 32-bit rather than 64-bit
-Fixed Deque being broken on 32-bit systems due to an errant int64_t
-Changed types of deque indexes from size_t to ssize_t; since they have to be signed for a moment to handle circling the buffer, the sign bit is lost for capacity anyway, and using signed indexes means...
-Deque and Vector now support negative indexing a la python list

#review-14122
#3 14066 ShadauxCat -Improved iterating in hashmap - range-based for now gives the ability to access both key and value instead of just value
-Slightly improved some of the template aliases
-Mega-deprecated VC11 support. Probably doesn't compile anymore. Maintaining it is too much of a headache.

#review-14067
#2 14015 ShadauxCat -Made reference counts in strings atomic
-Fixed an issue where items that were implicitly convertible to a hash map's value could not be inserted without explicit construction. (i.e., inserting a String object as map.insert("myString") would fail; it had to be map.insert(sprawl::String("myString")))
-Added template aliases for HashMap to simplify construction in simple single key/single value case
-Deprecated MSVC11 support.
#1 11496 ShadauxCat Initial checkin: Current states for csbuild and libSprawl