16 #ifndef SURGSIM_DATASTRUCTURES_GROUPS_H 17 #define SURGSIM_DATASTRUCTURES_GROUPS_H 19 #include <unordered_map> 20 #include <unordered_set> 23 #include <boost/thread.hpp> 29 namespace DataStructures
36 template <
typename Key,
typename T>
41 typedef Key IdentifierType;
49 bool add(
const Key& group,
const T& element);
56 bool add(
const std::vector<Key>& groups,
const T& element);
68 bool remove(
const Key& group,
const T& element);
73 bool remove(
const T& element);
78 std::vector<T>
getMembers(
const Key& group)
const;
83 std::vector<Key>
getGroups(
const T& element)
const;
91 std::vector<T>
operator[](
const Key& group)
const;
99 typedef boost::shared_lock<boost::shared_mutex> SharedLock;
100 typedef boost::unique_lock<boost::shared_mutex> UniqueLock;
103 mutable boost::shared_mutex m_mutex;
106 std::unordered_map<Key, std::unordered_set<T>> m_groups;
109 std::unordered_map<T, std::unordered_set<Key>> m_membership;
115 #include "SurgSim/DataStructures/Groups-inl.h" Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Class to wrap grouping operations, gives access to the members of a group and the groups of members...
Definition: Groups.h:37
std::vector< T > operator[](const Key &group) const
Return all the members of the given group.
Definition: Groups-inl.h:149
void clear()
Erases all entries.
Definition: Groups-inl.h:157
bool add(const Key &group, const T &element)
Add an element to the given group, if the group doesn't exist it will be created, if the element is a...
Definition: Groups-inl.h:25
std::vector< Key > getGroups() const
Definition: Groups-inl.h:117
std::vector< T > getMembers(const Key &group) const
Return all the members of the given group.
Definition: Groups-inl.h:91