Questions tagged [erase]

This tag refers to the process of removing or deleting data, text, files, or memory.

739 questions
5
votes
2 answers

How string pop_back is implemented in constant time?

std::string pop_back() : Remove the last element of the string In the C++ specification it is said that the C++11 string class function pop_back has a constant time complexity. (to be more precise - Unspecified but generally…
ralzaul
  • 4,280
  • 6
  • 32
  • 51
5
votes
2 answers

Any insights on how to make a canvas drawing not go on top on the other?

It's a preety straight up and basic question. I think that because that must be a often action there must be made function, but I can't find it? Is there one? If there isn't does anybody know how to do it?
raej99
  • 85
  • 5
5
votes
3 answers

How to erase a Hard Disk Drive

This is an odd question, but here it goes. I would like to write a program to flash my external hard drive with 1s and then 0s to clean it completely so I can sell it. Now, why do I want to write my own software instead of just using DBAN? From…
John Morgan
  • 121
  • 1
  • 3
4
votes
3 answers

How to get file physical location on hard drive

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…
Frank
  • 7,235
  • 9
  • 46
  • 56
4
votes
3 answers

Efficiently erasing elements in tr1::unordered_map

I am experimenting with tr1::unordered_map and stumbled upon the problem how to efficiently delete elements. The 'erase' method offers to delete either by key or by iterator. I would assume the latter to be more efficient, since the…
4
votes
2 answers

How could map::erase know if the interval is valid?

I'm writing a simple program which makes use of std::map::erase. The program is fine, but there is something I do not understand. If I pass to the erase function an interval in which the first iterator is beyond the second one, the function does not…
vaeVictis
  • 484
  • 1
  • 3
  • 13
4
votes
5 answers

Erase parts of drawings in OpenGL

I would like to know if it is possible to erase parts of any drawing in OpenGL? Lets say I have drawn two lines with my mouse and those lines are overlapping at some points. Is it possible to erase just one line? Is there a more or less simple…
buddy
  • 821
  • 2
  • 12
  • 30
4
votes
2 answers

Use of cbegin and cend in vector

I want to observe the difference between cbegin and begin. But when i use cbegin i am getting the same result as begin. According to definition cbegin will return const itertaor and we cant modify the element using the const iterator returned by…
4
votes
2 answers

Erase window background win32API

My classmates started using Delphi with pascal but I as c++ porgrammer have to use win32 API. They were changing background color so I need to know this aswell but there are some differencies. In delphi each form looks like it has it's own instance,…
Raven
  • 4,783
  • 8
  • 44
  • 75
4
votes
3 answers

Why no operator+ for std::list iterators?

I was about to write code like this: std::list mylist; // ... std::list::iterator it; for(it = mylist.begin(); it != mylist.end(); ++it) { // ... if(some condition) mylist.erase(it); } But I realized,…
Steve Summit
  • 45,437
  • 7
  • 70
  • 103
4
votes
2 answers

Calling erase() on an iterator, but not deleting correct element

I am learning C++ and I am working my way double linked lists, but I noticed something very peculiar when I was trying to delete elements from my list. Problem: I am inserting an element before the value of 2 in my list , numbers, and then I am…
Evan Gertis
  • 1,796
  • 2
  • 25
  • 59
4
votes
3 answers

golang erase symbols from console

I want to create animation in console, when program waits. There are a lot of simple ways to do this, usually, we just draw symbols in iterations of some cycle. Let our code be: func Spinner(delay time.Duration) { for !StopSpinner{ for…
4
votes
1 answer

Does a vector array resize after erasing one/more elements?

Does vector.erase resize the vector object so that I can measure the reduced size with vector.size()? for example; vector v(5); v = {1,2,3,4,5}; and I want to delete 4 by; v.erase(v.begin()+4); Does my vector object v have a size of 4 now. In…
Kishaan92
  • 155
  • 2
  • 8
4
votes
1 answer

Secure erasing of password from memory in Ruby

I'm writing a Ruby application that will need to handle a user's enterprise password. I'd like to minimize the time the password is in memory to reduce the likelihood of the password being exposed. In a native language, I would directly erase the…
Neil Smithline
  • 1,526
  • 9
  • 21
4
votes
4 answers

Segmentation fault when erasing elements while iterating std::deque

Why does the following code crash? And what should I do when I am iterating via reverse iterator. How do I erase individual elements then? deque q; q.push_back(4); q.push_back(41); q.push_back(14); for (auto it = q.begin(); it != q.end();) { …
Ram
  • 389
  • 4
  • 13