erase

C++ Erasing from list of pairs

这一生的挚爱 提交于 2019-11-29 18:13:34
Very simple: I have the following code and the method erase is not working. I do not see any problem there because if I go to http://www.cplusplus.com/reference/list/list/erase/ , syntax is: iterator erase (iterator position); list<pair<string,int>> l0 { { "name1", 20 }, { "name2", 30 }, { "name3", 40 } }; for( auto &it : l0 ) l0 . erase( it ); May there be a problem that there is a list of pair<string,int> and not a list of a basic data types? EDIT: The problem is that the code is not compilable. Christophe The range-for iterates through a container by giving you access to the elements in the

vector::erase with pointer member

本秂侑毒 提交于 2019-11-29 14:39:55
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 constructor necessary for support of vector::push_back() with visibleShape Hyp(const Hyp &other) { x = other.x; y = other.y; wFactor = other.wFactor; hFactor = other.hFactor; shapeNum = other.shapeNum; xmin = other.xmin; xmax = other.xmax; ymin = other.ymin; ymax = other

How do you erase *AND CONTINUE* using a std::reverse_iterator?

 ̄綄美尐妖づ 提交于 2019-11-29 04:13:58
I've been up and down stackoverflow and even the very, very nice Dr. Dobbs article but I can't find a definitive answer to the question. A section of the answer to the question What are the shortcomings of std::reverse_iterator? says that it might not be possible at all. std::list::reverse_iterator it = list.rbegin(); while( it != list.rend() ) { int value=*it; if( some_cond_met_on(value) ) { ++it; list.erase( it.base() ); } else { ++it; } } PS: I do know there are other alternatives, such as erase_if(), but I'm looking for an answer to this specific question. It should just be std::list<int>:

HTML5 Canvas eraser tool without overdraw white color

那年仲夏 提交于 2019-11-29 01:02:49
问题 I have canvas. I have paint tools pencil and eraser. How i can erase drawings without overwrite(overdraw) with white color. this my code eraser over drawing with white color: http://jsfiddle.net/66z12xb0/ I have in back end save image after drawing. <?php $images = scandir(ROOT_FS . FINISH_DRAW_PATH, 1); $imageData = $GLOBALS['HTTP_RAW_POST_DATA']; $filteredData = substr($imageData, strpos($imageData, ",") + 1); $unencodedData = base64_decode($filteredData); $fileName = "photo.png"; $fp =

Format SD card in Android

不打扰是莪最后的温柔 提交于 2019-11-28 21:52:59
Things should be simple, but as most of the time, in Android, aren't. I need to format the SD card if the user selects the option in my app. Don't ask me why I need to do this if it's already in the OS... not practical but it's a requirement that I need to implement. As you may know, there is an option in Settings \ Storage \ Erase SD Card . I took a look at the froyo source code and it's something like: final IMountService service = IMountService.Stub.asInterface(ServiceManager.getService("mount")); if (service != null) { new Thread() { public void run() { try { service.formatVolume

Erasing vector::end from vector

白昼怎懂夜的黑 提交于 2019-11-28 11:52:43
Does it works correct(does nothing) when I use vector<T> v; v.erase(v.end()); I want to use something like v.erase(std::find(...)); Should I if is it v.end() or not? There is no info about it on C++.com and CPPreference Steve Jessop The standard doesn't quite spell it out, but v.erase(q) is defined, "Erases the element pointed to by q " in [sequence.reqmts] . This means that q must actually point to an element, which the end iterator doesn't. Passing in the end iterator is undefined behavior. Unfortunately, you need to write: auto it = std::find(...); if (it != <the part of ... that specifies

vector::erase with pointer member

别说谁变了你拦得住时间么 提交于 2019-11-28 08:55:01
问题 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 constructor necessary for support of vector::push_back() with visibleShape Hyp(const Hyp &other) { x = other.x; y = other.y; wFactor = other.wFactor; hFactor = other

How to erase some portion of a UIImageView's image on iOS?

旧巷老猫 提交于 2019-11-28 07:06:40
I have a view with UIImageView and an image set to it. I want to erase the image as something like we do in photoshop with an eraser. How do I achieve this? Also, how do I undo erase? Ed Marty If you know what area you want to erase, you can create a new image of the same size, set the mask to the full image minus the area you want to erase, draw the full image into the new image, and use that as the new image. To undo, simply use the previous image. Edit Sample code. Say the area you want to erase from image view imgView is specified with by erasePath : - (void) clipImage { UIImage *img =

unlink vs remove in c++

女生的网名这么多〃 提交于 2019-11-28 05:42:33
What is the difference between remove and unlink functions in C++? Apart from the fact that unlink is unix-specific (as pointed out by Chris), we read in the POSIX manual: If path does not name a directory, remove(path) is equivalent to unlink(path). If path names a directory, remove(path) is equivalent to rmdir(path). As for the directory-passed unlink , we read: The path argument must not name a directory unless the process has appropriate privileges and the implementation supports using unlink() on directories. (...) Applications should use rmdir() to remove a directory. remove is portable,

How do you erase *AND CONTINUE* using a std::reverse_iterator?

点点圈 提交于 2019-11-27 18:18:17
问题 I've been up and down stackoverflow and even the very, very nice Dr. Dobbs article but I can't find a definitive answer to the question. A section of the answer to the question What are the shortcomings of std::reverse_iterator? says that it might not be possible at all. std::list::reverse_iterator it = list.rbegin(); while( it != list.rend() ) { int value=*it; if( some_cond_met_on(value) ) { ++it; list.erase( it.base() ); } else { ++it; } } PS: I do know there are other alternatives, such as