Questions tagged [remove-if]

Common Lisp 'remove-if' function.

Common Lisp 'remove-if' function.

It's signature is:

remove-if test sequence &key from-end start end count key => result-sequence

CLHS: remove-if

201 questions
1
vote
2 answers

Asymptotic complexity of std::remove_if

I am working on an erase method for a data structure with a hard-coded maximum number of elements, N, that relies on std::array to avoid heap memory. Although the std::array contains N elements only some number, M, of them are "relevant" elements…
asimes
  • 5,749
  • 5
  • 39
  • 76
1
vote
2 answers

counting deletions in remove_if (c++ STL)

Is there any way to count the number of deletions made by the remove_if function in the STL? Specifically I am passing forward and back iterators each to vectors of ints, and have a lambda as the third argument as a comparative value for remove_if…
user313
  • 681
  • 1
  • 8
  • 21
1
vote
1 answer

How to correctly detect an element which doesn't exist in another one with linq?

I have a table in DB which records printers related to an user profile. My db looks like this : |Date | UserID | PcId | PrinterId | ConfigId |... | 1 | 1 | 1 | 1 |... | 1 | 1 | 2 | 2 |... | 1 | 1 | …
mrplume
  • 183
  • 1
  • 3
  • 18
1
vote
2 answers

If one value exists then remove another

I'm stuck in my query on how to remove or rather skip a post if another one exists. This is my table. if L_ID column have value 821 AND 201 for the same P_ID then "remove" or don´t use 201 and sum() then time This would make P_ID 80 and 946 only…
Nils
  • 516
  • 3
  • 9
  • 33
1
vote
2 answers

std::list remove_if deletes nodes?

I have user-defined class like this: class Test { public: bool opeatator== (const Test& rhs) const { return this->value_ == rhs.value_; } int value_; }; I saved this pointer with std::list like this: std::list
P-P
  • 1,670
  • 5
  • 18
  • 35
1
vote
1 answer

A non-loop efficient way to erase from unordered_map with predicate C++11?

Algorithms and member functions are suggested over looping for efficiency when working with containers. However, associative containers (unordered_map) does not work with the erase(remove_if) paradigm, it appears that the common method is to fall…
Dave M
  • 11
  • 2
1
vote
0 answers

complete.case() remove NA in R

I have 8 columns in a data set. Some or all have NA. I want to remove all rows if any column has an NA. What i find is happening is that my code removes the rows if there is an NA in the first column but not any of the others. rawdata is the data…
1
vote
5 answers

Remove first element found with certainString from ArrayList?

I'm a COMPLETE beginner at coding. I was looking for the solution to this issue on this forum already but didn't manage to find it. Right now I am stuck with coding the method removeFirstNote(). Everytime I try to compile I get an error message…
1
vote
2 answers

Deleting a bunch of elements by their index?

I have a vector myVector; And I have a list of index to delete: vector deleteIndex; Which strategy would be the most efficient to delete those indexes? Actually one not efficient solution would be to: //> sort deleteindex auto…
anon
1
vote
2 answers

Using remove_if with C null-terminated string

I have a situation where I want to efficiently remove a character from a NULL-terminated char *. I can assume the incoming string is large (i.e. it wouldn't be efficient to copy); but I can also assume that I don't need to de-allocate the unused…
Tom
  • 2,369
  • 13
  • 21
1
vote
2 answers

list::remove_if equivalent

I'd like to know if its possible to represent this expression using remove_if and a lambda expression. std::list< gh::Actor* >::iterator astit = actors.begin(); while (astit != actors.end()) { if(…
Raúl Roa
  • 12,061
  • 13
  • 49
  • 64
1
vote
2 answers

How to remove special chars EXACTLY in .net 2.0, no linq is provided

I must to use .NET 2.0 and I have no Linq support here, also... I've tried to trim chars using Remove() and Trim() functions like: string guid = Guid.NewGuid().ToString(); string result = header.Trim( new Char[] { ' ', '-'} )); But for the…
Secret
  • 2,627
  • 7
  • 32
  • 46
1
vote
3 answers

REGEX - Remove specified string

I need help with Regex. I have words like "testBla", "Bla" and test". I want to cut the "test" from the "testBla". So it should only remove the "test" if the given string is larger than 4 characters. This is what i have: ^test\w{4,} but it doesn't…
Sylnois
  • 1,589
  • 6
  • 23
  • 47
1
vote
1 answer

How to remove duplicate entries if they occur within a certain time frame in R

I am trying to handle a database like the one below which has camera trap data. There is no lag between photos being taken so ones that occur in quick succession are likely to be the same individual. I want to remove duplicates of species if they…
0
votes
1 answer

How to use remove_if with erase

I would like to know how to remove an object from a list base on a condition. After researching, this is what I got, but it still doesn't work! So I would like to know how to use remove_if with erase. Class A { public: A(int x,int y); int…
mister
  • 3,303
  • 10
  • 31
  • 48