HashMap.hpp #3

  • //
  • guest/
  • ShadauxCat/
  • Sprawl/
  • Mainline/
  • collections/
  • HashMap.hpp
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#pragma once

//Support for legacy compilers lacking variadic template support
#if (defined(_WIN32) && _MSC_VER < 1800)
/*TODO: Support these too
|| (defined(__clang__) && (__clang_major__ < 2 || (__clang_major__ == 2 && __clang_minor__ < 9))) \
	|| (!defined(__clang__) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3))) \
	|| defined(SPRAWL_NO_VARIADIC_TEMPLATES)*/

#include "hashmap/HashMap_Windows.hpp"

namespace sprawl
{
	namespace collections
	{
		template<typename ValueType>
		class HashSet : public HashMap<ValueType, SelfAccessor<ValueType>, _MAX_NIL_LIST>
		{
			//
		};

		template<typename KeyType, typename ValueType>
		class BasicHashMap : public HashMap<ValueType, KeyAccessor<ValueType, KeyType>, _MAX_NIL_LIST>
		{
			//
		};
	}
}
#else
#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>>;

		template<typename KeyType, typename ValueType, KeyType(std::remove_reference<decltype(*(ValueType(nullptr)))>::type::*function)()>
		using PtrMemberHashMap = HashMap<ValueType, PtrMemberAccessor<typename std::remove_reference<decltype(*(ValueType(nullptr)))>::type, KeyType, function, ValueType>>;

		template<typename KeyType, typename ValueType, KeyType(std::remove_reference<decltype(*(ValueType(nullptr)))>::type::*function)() const>
		using PtrConstMemberHashMap = HashMap<ValueType, PtrConstMemberAccessor<typename std::remove_reference<decltype(*(ValueType(nullptr)))>::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 std::remove_reference<decltype(*(ValueType(nullptr)))>::type*)>
		using PtrFunctionHashMap = HashMap<ValueType, PtrFunctionAccessor<typename std::remove_reference<decltype(*(ValueType(nullptr)))>::type, KeyType, function, ValueType>>;
	}
}
#endif
# Change User Description Committed
#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