| 109 | /// \return The final hash code |
| 110 | template<typename T> |
| 111 | uintptr_t combineHash(const std::vector<std::shared_ptr<T> > &vector, bool withOrder) { |
| 112 | size_t count = vector.size(); |
| 113 | uintptr_t combinedHashcode = 0x1; |
| 114 | for (size_t i = 0; i < count; i++) { |
| 115 | auto hashNode = std::dynamic_pointer_cast<HashNode>(vector.at(i)); |
| 116 | if (hashNode != nullptr) { |
| 117 | combinedHashcode ^= (hashNode->hash()); |
| 118 | if (withOrder) |
| 119 | combinedHashcode ^= (127U * (i << 6)); |
| 120 | } |
| 121 | } |
| 122 | return combinedHashcode; |
| 123 | } |
| 124 | |
| 125 | /// Compute the hash code according to the given vector, and embed order index as well when possible. |
| 126 | /// \tparam Iter The class type for hashing |