erase

Multimap erase doesn't work

following code doesn't work with input: 2 7 add Elly 0888424242 add Elly 0883666666 queryname Elly querynum 0883266642 querynum 0888424242 delnum 0883666666 queryname Elly 3 add Kriss 42 add Elly 42 querynum 42 Why my erase doesn't work? #include<stdio.h> #include<iostream> #include<map> #include <string> using namespace std; void ...

vector::erase with pointer member

I am manipulating vectors of objects defined as follow: class Hyp{ public: int x; int y; double wFactor; double hFactor; char shapeNum; double* visibleShape; int xmin, xmax, ymin, ymax; Hyp(int xx, int yy, double ww, double hh, char s): x(xx), y(yy), wFactor(ww), hFactor(hh), shapeNum(s) {visibleShape=0;shapeNum=-1;}; //Copy constru...

OpenGl ES Eraser Tool

Hi Everyone, I am trying to implement an OpenGL eraser tool. I am struggling with this. I was thinking of painting somehow over the previous changes to "clear" out the changes. I can't use the background color because it is not a pattern, not one solid color. Can you point me to the right direction on how to implement an eraser tool...

Vector.erase(Iterator) causes bad memory access

Hi, I am trying to do a Z-Index reordering of videoObjects stored in a vector. The plan is to identify the videoObject which is going to be put on the first position of the vector, erase it and then insert it at the first position. Unfortunately the erase() function always causes bad memory access. Here is my code: testApp.h: vector...

How to find the four coordinates and erase drawing of an rubberband rectangle in C#

Hi I have tried to draw an rubberband rectangle on a form using the mouse in C#. Problems 1) After the mouse release the rectangle disappears. [I want it to stay on the form] 2) I also need to find the coordinates of the four points of the drawn rectangle 3) I also need to erase the rectangle to draw a new one when necessary Form :...

Drawing on Image in .NET - how to erase?

I'm planning to allow user drawing shapes and lines on image using mouse. If the background is solid, it's quite easy to build the eraser tool (simply fill with background color). But how to make it with image as background? ...

cycle and erase elments from std::set

I have a std::set and I need to erase similar adjacet elements: DnaSet::const_iterator next = dna_list.begin(); DnaSet::const_iterator actual = next; ++next; while(next != dna_list.end()) // cycle over pairs, dna_list is the set { if (similar(*actual, *next)) { Dna dna_temp(*actual); // copy constructor dna_lis...

Invalidating loop bounds

I've recently inherited a project primarily done in C++, so this is my first real exposure to it. I'm wondering if I may have a problem erasing a vector's elements from within a loop bounded by the vector's begin() and end(). Here's (essentially) what I've been trying to do: for (vector<double>::iterator i = distance.begin(); i < dista...

Does the "delete" statement doubly free an object?

Hello C++/STL gurus: Does the "delete" statement below "doubly free" an object? (...object_list is a global vector<object*>...) vector< object * >::iterator it, eit, iter; object *p_object; vector< object * > dead_objects; it = object_list_.begin(); eit = object_list_.end(); //---collect pointers of all dead objects to d...

erase whole array Python

Hey guys, how would you erase a whole array, as in it has no items. I want to do this so I could store new values (a new set of 100 floats) into it and find the minimum. Right now my program is reading the minimum from sets before I think because it is appending itself with the previous set still in there (i use .append by the way). ...

erase lines after drawing them in PyGTK- Cairo

hi, I want to ask how can I erase a line witch I've drawn by using the pyGTK I used:cairo library cr = widget.window.cairo_create() cr.move_to(x, y) cr.line_to(x1, y1) cr.stroke() I want to delete this line after drawing it on screen ...

Hiding/Removing/Fading CALayer erasing NSView contents

My situation: I have a single window with a content view (NSView), which has several subviews (plain NSControl subclasses; not important, just for testing) scattered around it. For part of the end effect I am trying to achieve, I want to place a semi-transparent black CALayer overlaying the whole window's content view, and be able to m...

C++ remove character from string

Hi! I am currently trying to implement deleting characters from a text field in C++. If the user hits Backspace, the following code is executed. There is currently no cursor, it should just remove the last character... if (mText.length() > 0){ mText.erase( mText.length() - 1, 1); // mText.resize(mText.length() - 1); } This wo...

How can i free a pointer vector?

Hello, how can i free up memory in a pointer vector? Here's the code: class A { private: int x,y,z; public: A(param1, param2, param3) { x=param1; y=param2; z=param3; } ~A() { //prompts an alertbox, warning me about the successful call...

How to define an iterator in a template?

Hello, I'm trying to define an iterator to iterate my map to erase it (destructor) I'm getting an error : incompatible iterator. My destructor looks like this : Consortium<S,T>::~Consortium() { map<const S, Node<T>*>::iterator deleteIterator; for (m_consortiumMap.begin() ; deleteIterator != m_consortiumMap.end() ; del...

C++ std::vector erasing element 0 throws exceptions

Sorry I can't provide code bc I don't have it. My coworker (who has been with the company for a long time but doesn't appear to know what he's doing) claims that he has to do some weird stuff to remove elements from a vector. He moves all the elements down a position (starting at the element that he wants to remove) then he'll remove t...

Erase-remove idiom with std::set failing with constness-related error

Can someone help me out here? Compiling this code: void test() { std::set<int> test; test.insert(42); test.erase(std::remove(test.begin(), test.end(), 30), test.end()); // <- Line 33 } Is generating the following error when compiling: $ make g++ -c -Wall -pedantic-errors -Wextra -Wunused -Werror a_star.cpp /usr/lib/gcc/i686-p...

C++: Loop over two vectors, remove elements of 1

Hi there, I have the following toy code, intended to remove duplicates from a vector: void overlap_removal(vector<int> &vec1, vector<int> &vec2) { for (vector<int>::iterator it1 = vec1.begin(); it1 != vec1.end(); ++it1) { for (vector<int>::iterator it2 = vec2.begin(); it2 != vec2.end(); ++it2) { if ((*it1)*(*it2) < 10) { ...

OpenMP parallelization and deleting from a vector of lists

Hi, gang. First, a high-level description of the problem & approach. I have a list containing images and pixel locations in each image - a list of lists. I want to pick n items at random from that list of images and for each image I want to iterate over k random pixel locations. I want to do this in parallel. For each processed pixel, I...

Removing something from a STL container without deconstructing it.

Ok, I'm using C++ STL containers (currently vector<customType*>). Now I need to remove elements from the container, but using erase deconstructs the object, which is bad, since I'm taking it off one, and putting it onto a variable doing some processing then onto another one. At the moment my code is quite nasty, and I'm just putting NUL...