forked from qt-creator/qt-creator
TaskTree: Add hash function for TreeStorageBase
Change-Id: Ia9242e3ca90ab13ee93fa42ebf86d03cc04fb669 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -14,6 +14,11 @@ bool TreeStorageBase::isValid() const
|
||||
return m_storageData && m_storageData->m_constructor && m_storageData->m_destructor;
|
||||
}
|
||||
|
||||
size_t TreeStorageBase::hash(uint seed) const
|
||||
{
|
||||
return size_t(m_storageData.get()) ^ seed;
|
||||
}
|
||||
|
||||
TreeStorageBase::TreeStorageBase(StorageConstructor ctor, StorageDestructor dtor)
|
||||
: m_storageData(new StorageData{ctor, dtor}) { }
|
||||
|
||||
|
@@ -35,6 +35,7 @@ public:
|
||||
{ return first.m_storageData == second.m_storageData; }
|
||||
friend bool operator!=(const TreeStorageBase &first, const TreeStorageBase &second)
|
||||
{ return first.m_storageData != second.m_storageData; }
|
||||
size_t hash(uint seed) const;
|
||||
|
||||
protected:
|
||||
using StorageConstructor = std::function<void *(void)>;
|
||||
@@ -60,6 +61,11 @@ private:
|
||||
friend TaskContainer;
|
||||
};
|
||||
|
||||
inline size_t qHash(const TreeStorageBase &storage, uint seed = 0)
|
||||
{
|
||||
return storage.hash(seed);
|
||||
}
|
||||
|
||||
template <typename StorageStruct>
|
||||
class TreeStorage : public TreeStorageBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user