+ vsize new_size = 0;
+ for (vsize i = 0; i < grobs_.size (); ++i)
+ if (Grob *grob = map_fun (grobs_[i]))
+ grobs_[new_size++] = grob;
+ grobs_.resize (new_size);
+ // could call grobs_.shrink_to_fit () with C++11
+}
+
+void
+Grob_array::filter_map_assign (const Grob_array &src,
+ Grob * (*map_fun) (Grob *))
+{
+ if (&src != this)
+ {
+ grobs_.resize (0);
+ grobs_.reserve (src.grobs_.size ());
+ for (vsize i = 0; i < src.grobs_.size (); i++)
+ if (Grob *grob = map_fun (src.grobs_[i]))
+ grobs_.push_back (grob);
+ // could call grobs_.shrink_to_fit () with C++11
+ }
+ else
+ filter_map (map_fun);