| 36 | } |
| 37 | |
| 38 | void |
| 39 | AnnotationLayerOp::erase (AnnotationShapes *shapes) |
| 40 | { |
| 41 | if (size_t (std::distance (shapes->begin (), shapes->end ())) <= m_shapes.size ()) { |
| 42 | // If all shapes are to be removed, just clear the list |
| 43 | shapes->clear (); |
| 44 | } else { |
| 45 | |
| 46 | // look up the shapes to delete and collect them in a sorted list. Then pass this to |
| 47 | // the erase_positions method of the shapes object |
| 48 | std::vector<bool> done; |
| 49 | done.resize (m_shapes.size (), false); |
| 50 | |
| 51 | std::sort (m_shapes.begin (), m_shapes.end ()); |
| 52 | |
| 53 | std::vector<shape_type>::const_iterator s_begin = m_shapes.begin (); |
| 54 | std::vector<shape_type>::const_iterator s_end = m_shapes.end (); |
| 55 | |
| 56 | std::vector<AnnotationShapes::layer_type::iterator> to_erase; |
| 57 | to_erase.reserve (m_shapes.size ()); |
| 58 | |
| 59 | // This is not quite effective but seems to be the simplest way |
| 60 | // of implementing this: search for each element and erase these. |
| 61 | for (AnnotationShapes::layer_type::iterator lsh = shapes->begin (); lsh != shapes->end (); ++lsh) { |
| 62 | std::vector<shape_type>::const_iterator s = std::lower_bound (s_begin, s_end, *lsh); |
| 63 | while (s != s_end && *s == *lsh && done [std::distance(s_begin, s)]) { |
| 64 | ++s; |
| 65 | } |
| 66 | if (s != s_end && *s == *lsh) { |
| 67 | done [std::distance(s_begin, s)] = true; |
| 68 | to_erase.push_back (lsh); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | shapes->erase_positions (to_erase.begin (), to_erase.end ()); |
| 73 | |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // --------------------------------------------------------------------------------------- |
| 78 | // Shapes implementation |
nothing calls this directly
no test coverage detected