Clearing an array of defined element(s) - page 23

 
Maxim Kuznetsov:
I think Nicholas will just complete it, there's nothing to compare it with :-) Peter's timing is infinite.

Well, yes. There's no point in comparing it with infinity - there will be infinity in any case. But I was referring to Peter's current flight time for comparison.

 
Artyom Trishkin:

Yes, there's no point in comparing it to infinity - there will be infinity in any case. But I was referring to Peter's current flight time for comparison.

Incorrect code and, as a consequence, incorrect results. I can fight a little bit.

 
OK, guys, we've had enough of kindergarten. )) Nikolai, I wish you creative victories!
 
Реter Konow:

Start the same project. You'll find out).

my projects are in a completely different field. I have already said that your project was relevant at the end of the 1980s.
Anatoly did a very sensible thing. Not only did he earn points in this community, but he was also able to monetize his work by publishing 70 articles.

But your project, Pyotr, is a Sisyphean task. I told you this a year and a half ago.

 

Whose algorithm is best suited to minor changes in requirements?

int array_filter(int &array[], const int &multiple_filters[]);


int array_filter(int &arr[], const int &filters[])
{
   int size_arr = ArraySize(arr);
   int size_filters = ArraySize(filters);
   int i=0, j=0, k=0;
   for(i=0; i<size_arr; i++){
      for(j=size_filters-1; j>=0; --j)
         if(arr[i] == filters[j])
            break;
      if(j < 0)
         arr[k++] = arr[i]; 
   }
   return ArrayResize(arr, k); 
}
 
nicholi shen:

Whose algorithm is best suited to minor changes in requirements?

And what is the question. In a simple array comparison? What changes, what requirements?

The right question. Half the answer.

 
Konstantin Nikitin:

And what is the question. In a simple array comparison? What changes, what requirements?


The original source array is now filtered by a list of values instead of a single value.

 
nicholi shen:

Whose algorithm is best suited to minor changes in requirements?


if muliple_filters is not too big, then any... if it is big, then there may be special algorithms for comparison of sets (in essence: the whole task is to subtract from one set another)

In general, filter can be of the form:

int array_filter(const T &src[], T &dst, bool (*filter_condition)(const T));

and allow src, dst to refer to the same array.

So you can e.g. discard all numbers that fall (or don't fall) into the range.

---

Any of the presented algorithms can be clothed in a similar form. (instead of comparing with constant X, it will be a function call, (or as in your case finding an element in an array) )

 
nicholi shen:


The original source array is now filtered by a list of values instead of a single value.

I'm sorry to hear that.

 
Maxim Kuznetsov:

if muliple_filters is not too big, then any... if big, then there can be special algorithms for comparison of sets (basically: the whole task is to subtract from one set another)

In general, the filter can be of the form:

int array_filter(const T &src[], T &dst, bool (*filter_condition)(const T));

and allow src, dst to refer to the same array.

To be able to e.g. discard all numbers that fall (or not) into the range.

---

Any of the presented algorithms can be clothed in a similar form. (instead of comparing with constant X, it will be a function call, (or as in your case finding an element in an array) )

He's not Russian, so it's hard to understand. El habla espanol.

Reason: