erase

Linked List Delete Node , Simple linked list

有些话、适合烂在心里 提交于 2021-02-17 02:08:34
问题 I'm trying to implement a function that deletes nodes from a linked list. So far, I can delete just the first node of the list(3). I tried to go to the for loop from delete, I thought that the memory is not well allocated, I have been struggling for a few days and I don't understand, please help me a little, it's the topic I received from college. #include <stdio.h> #include <stdlib.h> typedef struct nod { int key; struct nod *urm; } NOD; NOD *first=0,*last=0; void add(int x) { NOD *p=(NOD*

Linked List Delete Node , Simple linked list

邮差的信 提交于 2021-02-17 02:08:25
问题 I'm trying to implement a function that deletes nodes from a linked list. So far, I can delete just the first node of the list(3). I tried to go to the for loop from delete, I thought that the memory is not well allocated, I have been struggling for a few days and I don't understand, please help me a little, it's the topic I received from college. #include <stdio.h> #include <stdlib.h> typedef struct nod { int key; struct nod *urm; } NOD; NOD *first=0,*last=0; void add(int x) { NOD *p=(NOD*

C++ nested for loop with erasing elements

荒凉一梦 提交于 2021-02-11 14:14:20
问题 I would like to check all Elements of an vector against each other. By checking a condition an element should be removed. One approach was to erase the elements by nested for loops for (int a = 0; a < rs.size(); a++) { Point A = rs[a]; for (int b = 1; b <= rs.size(); b++) { Point B = rs2[b]; float distance = sqrt(pow(B.x - A.x, 2) + pow(B.y - A.y, 2) * 1.0); if (distance < 10.0) { if (distance > 0) { rs.erase(rs.begin() + b); } } } } but this would effect the vector and his size in runtime. A

C++ nested for loop with erasing elements

你离开我真会死。 提交于 2021-02-11 14:10:27
问题 I would like to check all Elements of an vector against each other. By checking a condition an element should be removed. One approach was to erase the elements by nested for loops for (int a = 0; a < rs.size(); a++) { Point A = rs[a]; for (int b = 1; b <= rs.size(); b++) { Point B = rs2[b]; float distance = sqrt(pow(B.x - A.x, 2) + pow(B.y - A.y, 2) * 1.0); if (distance < 10.0) { if (distance > 0) { rs.erase(rs.begin() + b); } } } } but this would effect the vector and his size in runtime. A

MATLAB: How to delete characters from 2x1 or nx1 string?

。_饼干妹妹 提交于 2021-01-29 07:17:24
问题 Good day. Here I have a 2x1 string: A = ["CHAPTER 1. Random info in middle one, Random info still continues. 1";... "CHAPTER 2. Random info in middle two. Random info still continues. 1"]; How can I remove "CHAPTER #", and the last number and space at the back of the space? Here is my attempt: %PlanA for n=1:2 % Delete "Chapter+Nr" A(n,1) = erase(A,'(CHAPTER \d)'); % Delete last nr 1 at end A(n,1) = erase(A,'\d'); end %PlanB A(strcmp(A, 'CHAPTER \d')) = [] I have no idea why this is not

Erase in a loop with a condition in C++

狂风中的少年 提交于 2021-01-27 12:46:32
问题 Is there a better way to write: for (auto i = container.begin(); i != container.end();) { if (condition(i)) { i = container.erase(i); continue; } ++i; } This code does what I want, but it feels like bad style. How can I improve it? My container is std::map , but a generic solution would be cool. 回答1: Use erase + remove_if : auto pred = /* lambda or something*/ container.erase(std::remove_if(container.begin(), container.end(), pred) 回答2: Is there a better way to...? It is always subjective,

How to implement touch smooth image eraser in android?

对着背影说爱祢 提交于 2021-01-27 07:26:43
问题 I have already seen fingurePaint.java from API demos. I want to implement touch smooth eraser to erase parts of the image by touch move in android. fingurePaint told me to implement this mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); But this is not working to erase the image. It is working to erase something which is drawn by touch. public class SandboxView extends View implements OnTouchListener { public final Bitmap bitmap; private final int width; private final int

How to implement touch smooth image eraser in android?

笑着哭i 提交于 2021-01-27 07:24:58
问题 I have already seen fingurePaint.java from API demos. I want to implement touch smooth eraser to erase parts of the image by touch move in android. fingurePaint told me to implement this mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); But this is not working to erase the image. It is working to erase something which is drawn by touch. public class SandboxView extends View implements OnTouchListener { public final Bitmap bitmap; private final int width; private final int

How to implement touch smooth image eraser in android?

早过忘川 提交于 2021-01-27 07:24:28
问题 I have already seen fingurePaint.java from API demos. I want to implement touch smooth eraser to erase parts of the image by touch move in android. fingurePaint told me to implement this mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); But this is not working to erase the image. It is working to erase something which is drawn by touch. public class SandboxView extends View implements OnTouchListener { public final Bitmap bitmap; private final int width; private final int

Secure erasing of password from memory in Ruby

纵然是瞬间 提交于 2020-12-09 05:20:25
问题 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 data. In C#, I would use the SecureString class. In Java, I'd use char[]. But the best that I can find for Ruby is an old feature request that seems dead. What is the standard for securely storing and erasing passwords from memory in Ruby? Is there a