erase

Format SD card in Android

本小妞迷上赌 提交于 2019-11-27 14:06:20
问题 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(

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

大城市里の小女人 提交于 2019-11-27 12:49:32
This question already has an answer here: Deleting elements from STL set while iterating 8 answers 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-pc-cygwin/4.3.4/include/c++/bits/stl_algo.h: In function `_FIter std::remove(_FIter, _FIter, const _Tp&) [with _FIter = std::_Rb_tree_const_iterator<int>, _Tp = int]': a_star

How to erase & delete pointers to objects stored in a vector?

☆樱花仙子☆ 提交于 2019-11-27 11:03:05
I have a vector that stores pointers to many objects instantiated dynamically, and I'm trying to iterate through the vector and remove certain elements (remove from vector and destroy object), but I'm having trouble. Here's what it looks like: vector<Entity*> Entities; /* Fill vector here */ vector<Entity*>::iterator it; for(it=Entities.begin(); it!=Entities.end(); it++) if((*it)->getXPos() > 1.5f) Entities.erase(it); When any of the Entity objects get to xPos>1.5, the program crashes with an assertion error... Anyone know what I'm doing wrong? I'm using VC++ 2008. You need to be careful

Erasing vector::end from vector

懵懂的女人 提交于 2019-11-27 03:02:44
问题 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 回答1: 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.

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

非 Y 不嫁゛ 提交于 2019-11-27 01:43:39
问题 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? 回答1: 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

unlink vs remove in c++

与世无争的帅哥 提交于 2019-11-27 01:01:03
问题 What is the difference between remove and unlink functions in C++? 回答1: 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

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

混江龙づ霸主 提交于 2019-11-26 16:10:39
问题 This question already has answers here : Deleting elements from std::set while iterating (8 answers) Closed 6 months ago . 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-pc-cygwin/4.3.4/include/c++/bits/stl_algo.h: In

How to erase & delete pointers to objects stored in a vector?

孤人 提交于 2019-11-26 15:24:24
问题 I have a vector that stores pointers to many objects instantiated dynamically, and I'm trying to iterate through the vector and remove certain elements (remove from vector and destroy object), but I'm having trouble. Here's what it looks like: vector<Entity*> Entities; /* Fill vector here */ vector<Entity*>::iterator it; for(it=Entities.begin(); it!=Entities.end(); it++) if((*it)->getXPos() > 1.5f) Entities.erase(it); When any of the Entity objects get to xPos>1.5, the program crashes with an

Erase the current printed console line

亡梦爱人 提交于 2019-11-26 14:14:18
How can I erase the current printed console line in C? I am working on a Linux system. For example - printf("hello"); printf("bye"); I want to print bye on the same line in place of hello. mouviciel You can use VT100 escape codes . Most terminals, including xterm, are VT100 aware. For erasing a line, this is ^[[2K . In C this gives: printf("%c[2K", 27); Andre Miller You can use a \r ( carriage return ) to return the cursor to the beginning of the line: printf("hello"); printf("\rbye"); This will print bye on the same line. It won't erase the existing characters though, and because bye is

C++ Erase vector element by value rather than by position? [duplicate]

两盒软妹~` 提交于 2019-11-26 12:00:00
This question already has an answer here: How do I remove an item from a stl vector with a certain value? 10 answers vector<int> myVector; and lets say the values in the vector are this (in this order): 5 9 2 8 0 7 If I wanted to erase the element that contains the value of "8", I think I would do this: myVector.erase(myVector.begin()+4); Because that would erase the 4th element. But is there any way to erase an element based off of the value "8"? Like: myVector.eraseElementWhoseValueIs(8); Or do I simply just need to iterate through all the vector elements and test their values? Georg