#pragma once #include "../../common/specialized.hpp" #include "../../common/compat.hpp" namespace sprawl { namespace collections { namespace detail { template<typename ValueType, typename MostInheritedType, size_t index, typename... AdditionalAccessors> class AccessorGroup_Impl; template<typename ValueType, typename MostInheritedType, size_t index> class AccessorGroup_Impl<ValueType, MostInheritedType, index> { public: AccessorGroup_Impl(ValueType const& value) : next(nullptr) , prev(nullptr) , m_value(value) { // } AccessorGroup_Impl(AccessorGroup_Impl const& other) : next(nullptr) , prev(nullptr) , m_value(other.m_value) { // } inline MostInheritedType* Next(Specialized<index>) { return nullptr; } inline MostInheritedType* Prev(Specialized<index>) { return nullptr; } inline void SetNext(Specialized<index>, MostInheritedType*) { // } inline void SetPrev(Specialized<index>, MostInheritedType*) { // } inline size_t Idx(Specialized<index>) { return -1; } inline void SetIndex(Specialized<index>, size_t) { // } inline size_t GetHash(Specialized<index>) { return -1; } inline void SetHash(Specialized<index>, size_t) { // } inline NullAccessor& Accessor(Specialized<index>) { static NullAccessor accessor; return accessor; } MostInheritedType* next; MostInheritedType* prev; ValueType m_value; }; template<typename ValueType, typename MostInheritedType, size_t index, typename AccessorType, typename... AdditionalAccessors> class AccessorGroup_Impl<ValueType, MostInheritedType, index, AccessorType, AdditionalAccessors...> : public AccessorGroup_Impl<ValueType, MostInheritedType, index+1, AdditionalAccessors...> { public: typedef AccessorGroup_Impl<ValueType, MostInheritedType, index+1, AdditionalAccessors...> Base; AccessorGroup_Impl(ValueType const& value) : Base(value) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } AccessorGroup_Impl(AccessorGroup_Impl const& other) : Base(other) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } template<typename... Params> AccessorGroup_Impl(ValueType const& value, typename AccessorType::arg_type const& key, Params... moreKeys) : Base(value, moreKeys...) , m_thisAccessor(this->m_value, key) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } template<typename... Params> AccessorGroup_Impl(ValueType const& value, Params... moreKeys) : Base(value, moreKeys...) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } using Base::Next; inline MostInheritedType* Next(Specialized<index>) { return m_nextThisAccessor; } using Base::Prev; inline MostInheritedType* Prev(Specialized<index>) { return m_prevThisAccessor; } using Base::SetNext; inline void SetNext(Specialized<index>, MostInheritedType* next) { m_nextThisAccessor = next; } using Base::SetPrev; inline void SetPrev(Specialized<index>, MostInheritedType* prev) { m_prevThisAccessor = prev; } using Base::Idx; inline size_t Idx(Specialized<index>) { return m_thisIdx; } using Base::SetIndex; inline void SetIndex(Specialized<index>, size_t idx) { m_thisIdx = idx; } using Base::GetHash; inline size_t GetHash(Specialized<index>) { return m_thisHash; } using Base::SetHash; inline void SetHash(Specialized<index>, size_t hash) { m_thisHash = hash; } using Base::Accessor; inline AccessorType& Accessor(Specialized<index>) { return m_thisAccessor; } AccessorType m_thisAccessor; MostInheritedType* m_nextThisAccessor; MostInheritedType* m_prevThisAccessor; size_t m_thisIdx; size_t m_thisHash; }; template<typename ValueType, typename... Accessors> class AccessorGroup : public AccessorGroup_Impl<ValueType, AccessorGroup<ValueType, Accessors...>, 0, Accessors...> { public: typedef AccessorGroup_Impl<ValueType, AccessorGroup<ValueType, Accessors...>, 0, Accessors...> Base; AccessorGroup(ValueType const& value) : Base(value) { // } template<typename... Params> AccessorGroup(ValueType const& value, Params... keys) : Base(value, keys...) { // } }; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 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 |
||
#5 | 14081 | ShadauxCat |
-Switching order of keys and values in HashMap::insert(). Keys now come first - a number of parameters equal to the number of keys. (Simple case is simply insert(key, value)) -Added move constructors to AccessorGroup so things can be inserted into the map via rvalue references -Fixed ForwardList's copy constructor copying things in reverse and added a unit test to make sure it doesn't happen again. #review-14079 |
||
#4 | 14068 | ShadauxCat |
Fixed broken copy constructor in AccessorGroup with a KeyAccessor #review-14069 |
||
#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 |