void
MultiGridSubsetHandler::
assign_subset_impl(TElem* elem, int subsetIndex)
{
	assert((m_pGrid != NULL) && "ERROR in SubsetHandler::assign_subset(): No grid assigned to SubsetHandler.");

	int level = m_pMG->get_level(elem);

//	check if we have to remove elem from a subset.
	int oldIndex = get_subset_index(elem);
	
	if(oldIndex != -1)
		section_container<TElem>(oldIndex, level).erase(get_list_iterator(elem), elem->container_section());

//	add the element to the subset.
	if(subsetIndex != -1)
	{
		subset_required(subsetIndex);
		level_required(level);
		section_container<TElem>(subsetIndex, level).insert(elem, elem->container_section());
		subset_assigned(elem, subsetIndex);
	}
	else {
//TODO:	iterator is useless!
		subset_assigned(elem, -1);
	}
}
Exemplo n.º 2
0
 void erase(const group_key_type &key)
 {
   map_iterator map_it = _group_map.lower_bound(key);
   iterator begin_list_it = get_list_iterator(map_it);
   iterator end_list_it = upper_bound(key);
   if(begin_list_it != end_list_it)
   {
     _list.erase(begin_list_it, end_list_it);
     _group_map.erase(map_it);
   }
 }
Exemplo n.º 3
0
 void m_insert(const map_iterator &map_it, const group_key_type &key, const ValueType &value)
 {
   iterator list_it = get_list_iterator(map_it);
   iterator new_it = _list.insert(list_it, value);
   if(map_it != _group_map.end() && weakly_equivalent(key, map_it->first))
   {
     _group_map.erase(map_it);
   }
   map_iterator lower_bound_it = _group_map.lower_bound(key);
   if(lower_bound_it == _group_map.end() ||
     weakly_equivalent(lower_bound_it->first, key) == false)
   {
     /* doing the following instead of just
       _group_map[key] = new_it;
       to avoid bogus error when enabling checked iterators with g++ */
     _group_map.insert(typename map_type::value_type(key, new_it));
   }
 }
Exemplo n.º 4
0
 iterator upper_bound(const group_key_type &key)
 {
   map_iterator map_it = _group_map.upper_bound(key);
   return get_list_iterator(map_it);
 }