Lines Matching refs:element
44 // that can serve as a key in a map or an element of a set.
46 // An element can only belong to one group at a time. A group may
53 // Add an element to a group. If a group with this id does not
55 // times for the same element. Group ids should be non-negative
58 // Return value indicates if adding the element was a success.
59 bool AddElementToGroup(const T element, const int group) {
64 typename map<T, int>::const_iterator it = element_to_group_.find(element);
67 // Element is already in the right group, nothing to do.
71 group_to_elements_[it->second].erase(element);
77 element_to_group_[element] = group;
78 group_to_elements_[group].insert(element);
87 // Remove the element, no matter what group it is in. If the element
91 // Return value indicates if the element was actually removed.
92 bool Remove(const T element) {
93 const int current_group = GroupId(element);
98 group_to_elements_[current_group].erase(element);
105 element_to_group_.erase(element);
130 // Return the group id for the element. If the element is not a
132 int GroupId(const T element) const {
133 typename map<T, int>::const_iterator it = element_to_group_.find(element);
140 bool IsMember(const T element) const {
141 typename map<T, int>::const_iterator it = element_to_group_.find(element);