33 #ifndef DART_COLLISION_DETAIL_UNORDEREDPAIRS_HPP_
34 #define DART_COLLISION_DETAIL_UNORDEREDPAIRS_HPP_
36 #include <unordered_map>
37 #include <unordered_set>
48 void addPair(
const T* left,
const T* right);
57 bool contains(
const T* left,
const T* right)
const;
65 std::unordered_map<const T*, std::unordered_set<const T*>>
mList;
75 const auto* less = left;
76 const auto* greater = right;
79 std::swap(less, greater);
84 const auto itLess = mList.insert(
85 std::make_pair(less, std::unordered_set<const T*>())).first;
89 itLess->second.insert(greater);
99 const auto* bodyNodeLess = left;
100 const auto* bodyNodeGreater = right;
102 if (bodyNodeLess > bodyNodeGreater)
103 std::swap(bodyNodeLess, bodyNodeGreater);
106 const auto resultLeft = mList.find(bodyNodeLess);
107 const bool foundLeft = (resultLeft != mList.end());
110 auto& associatedRights = resultLeft->second;
111 associatedRights.erase(bodyNodeGreater);
113 if (associatedRights.empty())
114 mList.erase(resultLeft);
129 const auto* less = left;
130 const auto* greater = right;
133 std::swap(less, greater);
135 const auto resultLeft = mList.find(less);
136 const bool foundLeft = (resultLeft != mList.end());
139 auto& associatedRights = resultLeft->second;
141 const auto resultRight = associatedRights.find(greater);
142 const bool foundRight = (resultRight != associatedRights.end());
Definition: UnorderedPairs.hpp:45
void removeAllPairs()
Removes all the pairs from this container.
Definition: UnorderedPairs.hpp:120
std::unordered_map< const T *, std::unordered_set< const T * > > mList
The actual container to store pairs.
Definition: UnorderedPairs.hpp:65
void removePair(const T *left, const T *right)
Removes a pair from this container.
Definition: UnorderedPairs.hpp:94
void addPair(const T *left, const T *right)
Adds a pair to this container.
Definition: UnorderedPairs.hpp:70
bool contains(const T *left, const T *right) const
Returns true if this container contains the pair.
Definition: UnorderedPairs.hpp:127
Definition: BulletCollisionDetector.cpp:63