erase

Does using the erase function in a string invalidate iterators

耗尽温柔 提交于 2019-12-11 04:24:26
问题 I have the following code that takes a string and erases non alphabet characters void removeNonAlpha(string& str){ for (string::iterator it = str.begin(); it < str.end(); it++){ if (!(isUpperCaseLetter(*it) || isLowerCaseLetter(*it) || str == ' ')) str.erase(it--); } } I showed this to my professor and he told me that doing this is risky because it may invalidate the iterator that I'm using. However, I thought that erase will only invalidate iterators after the point of the erase, and I made

Help with eraser from buffered Image

感情迁移 提交于 2019-12-11 02:24:47
问题 So below I am working on a paint type project for class that lets you draw shapes lines etc, now my professor wants us to add a eraser tool that lets you erase parts of the image, it is on a buffered image any ideas? im fresh out import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.*; public class PaintProgram extends JPanel implements MouseListener

AS3 How to check if BitmapData is empty

﹥>﹥吖頭↗ 提交于 2019-12-10 19:03:14
问题 I have a code to erase a masked movieclip. (credits here) I would like to know how I can check if the whole movieclip is been erased. So I thought I had to check if the BitmapData is empty, but I could be terribly wrong! How can I check if every pixel of the movieclip has been erased? Of course my example below is wrong, but I think it has to be something like that. if (erasableBitmapData = empty) { trace("empty") } var lineSize:Number=40; var doDraw:Boolean=false; var resumeDrawing:Boolean

Python securely remove file

人走茶凉 提交于 2019-12-10 14:19:40
问题 How can I securely remove a file using python? The function os.remove(path) only removes the directory entry, but I want to securely remove the file, similar to the apple feature called "Secure Empty Trash" that randomly overwrites the file. What function securely removes a file using this method? 回答1: You can use srm to securely remove files. You can use Python's os.system() function to call srm. 回答2: You can use srm , sure, you can always easily implement it in Python. Refer to wikipedia

How to erase image by using touch in objective-c iOS?

拈花ヽ惹草 提交于 2019-12-10 12:31:11
问题 I am working on a project where I have added a UIImage above another Image. Now, I have to erase some part or whole of that top image by using smooth touch. I have seen many other questions which are quite similar to mine. But they are not properly answered or might not worked in my case. Please suggest me some sample code or any tutorial for this. Thanks in advance 回答1: create image view..... - (void)viewDidLoad { eraseimg1 = [[UIImageView alloc] initWithFrame:CGRectMake(20,100, 80, 80)];

c++ stl what does base() do

谁说我不能喝 提交于 2019-12-09 04:39:06
问题 I have such code : vector <int> v; for (int i=0; i<5; i++) v.push_back(i); v.erase(find(v.rbegin(), v.rend(),2).base()); This code deletes the first element from vector v after first detected 2 (in vector remain: 0 1 2 4). What does .base() do here? 回答1: base() converts a reverse iterator into the corresponding forward iterator. However, despite its simplicity, this correspondence is not as trivial as one might thing. When a reverse iterator points at one element, it dereferences the previous

PHP session variable shows as empty on refresh

☆樱花仙子☆ 提交于 2019-12-08 07:40:51
问题 To pretty up my url and make the multi-step activation process easier, I've programmed my page to store the userID and activation code from the activation email as session variables. When a userID and actCode are in the url, it saves them as session variables, then redirects to activate (I've used htaccess to take off the .php part) It works the first time (when the page refreshes itself) but when you move to a different step or refresh the page manually, it erases them. Here's my code: <?php

How to get file physical location on hard drive

笑着哭i 提交于 2019-12-07 12:12:30
问题 I want to make a file shedder to completely delete a file, by writing zeros to its physical areas. Files may be stored on hard drive in pieces, not always in a whole block. When I say physical areas. I mean the physical sections that the file is stored, or any reference to those sections that I can perform "writing zeros". Better in C#. 回答1: Unfortunately, that is not entirely possible in C# and neither in C/C++ for that matter even if you are writing a kernel mode driver. Quote from the

How to erase path area from canvas (Android)

爷,独闯天下 提交于 2019-12-07 08:10:46
问题 I need to crop corners on ImageView . Not to round them but erase triangles from each corner. Seems like the only way to do that is to override onDraw method and erase these areas from canvas using Path . The problem is I have not solid color background, so I need ERASE these areas but not to fill them with some color. I use following code for that: @Override protected void onDraw(Canvas canvas) { Path path = new Path(); path.moveTo(0, 0); path.lineTo(20, 0); path.lineTo(0, 20); path.close();

Problem with invalidation of STL iterators when calling erase

走远了吗. 提交于 2019-12-06 05:45:48
问题 The STL standard defines that when an erase occurs on containers such as std::deque, std::list etc iterators are invalidated. My question is as follows, assuming the list of integers contained in a std::deque, and a pair of indicies indicating a range of elements in the std::deque, what is the correct way to delete all even elements? So far I have the following, however the problem here is that the assumed end is invalidated after an erase: #include <cstddef> #include <deque> int main() { std