BinaryTree.hpp #2

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

#include "binarytree/BinaryTree_Variadic.hpp"

namespace sprawl
{
	namespace collections
	{
		template<typename ValueType>
		using BinarySet = BinaryTree<ValueType, SelfAccessor<ValueType>>;

		template<typename KeyType, typename ValueType>
		using BasicBinaryTree = BinaryTree<ValueType, KeyAccessor<ValueType, KeyType>>;

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

		template<typename KeyType, typename ValueType, KeyType(ValueType::*function)() const>
		using ConstMemberBinaryTree = BinaryTree<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 PtrMemberBinaryTree = BinaryTree<ValueType, PtrMemberAccessor<typename detail::UnderlyingType<ValueType>::type, KeyType, function, ValueType>>;

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

		template<typename KeyType, typename ValueType, KeyType(*function)(ValueType*)>
		using FunctionBinaryTree = BinaryTree<ValueType, FunctionAccessor<ValueType, KeyType, function>>;

		template<typename KeyType, typename ValueType, KeyType(*function)(typename detail::UnderlyingType<ValueType>::type*)>
		using PtrFunctionBinaryTree = BinaryTree<ValueType, PtrFunctionAccessor<typename detail::UnderlyingType<ValueType>::type, KeyType, function, ValueType>>;
	}
}
# Change User Description Committed
#3 14833 ShadauxCat First checkin of logging module.

Also fixes the following issues:

-Added UpperBound() and LowerBound() to BinaryTree and created appropriate unit tests
-Added Sync() to ThreadManager to force it to run all tasks to completion and not return until it has no tasks left
-Fixed a bug in String::format() where a non-numeric value inside {} would be treated as an empty {}; it now simply prints whatever the value was. (i.e., "{blah}".format(foo) simply returns "{blah}")
-Added Reset() to sprawl::StringBuilder
-Disabled the switch-enum warning flag in gcc because it's stupid and ridiculous that a default case doesn't shut it up
-Made sprawl::Mutex movable. This may turn out to be a bad idea but it enabled keeping them in a map.
-Fixed a name collission between HashMap and BinaryTree; both defined sprawl::collections::detail::UnderlyingType and ::MethodType. Prefixed the ones in BinaryTree with "Tree". This isn't the best solution, but it works for now.

#review-14834
#2 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
#1 11496 ShadauxCat Initial checkin: Current states for csbuild and libSprawl