template<typename T>
int EraseRate(T &tArray[],T tRate){
int tCount=ArraySize(tArray),
tRes=tCount;
for (int i=0,ii=0;i+ii<tCount;i++){
if (ii) tArray[i]=tArray[i+ii];
while (tArray[i]==tRate&&i+ii<tCount){
if (i+(++ii)<tCount) tArray[i]=tArray[i+ii];
tRes--;}}
return(ArrayResize(tArray,tRes));}
template<typename T>
int EraseRate(T &tArray[],T tRate){
int tCount=ArraySize(tArray),
tDelCount=0;
for (int i=0,tNext=0;tNext<tCount;i++,tNext++){
if (tDelCount) tArray[i]=tArray[tNext];
while (tArray[i]==tRate&&tNext<tCount){
if (++tNext<tCount) tArray[i]=tArray[tNext];
tDelCount++;}}
return(ArrayResize(tArray,tCount-tDelCount));}
/*
//the original code of nicholi shen
int array_filter(int &a[],const int &b[])
{
int e=ArraySize(a);
bool c[];
int d = ArrayResize(c, b[ArrayMaximum(b)] + 1);
ArrayInitialize(c, 0);
for(int i=ArraySize(b)-1; i>=0; --i)
c[b[i]] = 1;
int g=0, h=0, f=0;
for(g=0; g<e; g++){
f = a[g];
if(f >= d || !c[f]){
a[h]=f;
h++;
}
}
return ArrayResize(a, h);
}
*///by Stanislav_Dray, based on the code aboveint ArrayDeleteVectorINT(int &A[],constint &F[])
{
if(!ArrayIsDynamic(A))
{
Print(__FUNCTION__,": cannot be used for static allocated array");
return(-1);
}
int Fp[];
int A_size=ArraySize(A);
int F_size=ArraySize(F);
int F_maxval=F[ArrayMaximum(F)];
int F_minval=F[ArrayMinimum(F)];
//extra memory needed : ExtraMemory*sizeof(int)int ExtraMemory=((MathMax(F_maxval,MathAbs(F_minval)))>>5) + 1;
if(ArrayResize(Fp,ExtraMemory)==-1)
{
Print(__FUNCTION__,": cannot allocate memory");
return(-1);
}
int h;
int i;
int j;
int A_value;
int F_value;
if(F_maxval>=0)
{
ArrayInitialize(Fp, 0);
i=0;h=0;
while(i<F_size)
{
F_value=F[i];
if(F_value>-1)
{
j=F_value>>5;
Fp[j]|=(1<<(F_value-(j<<5)));
}
i++;
}
for(i=0; i<A_size; i++)
{
A_value = A[i];
if(A_value>F_maxval || A_value<0)
{
A[h]=A_value;
h++;
}else
{
j=A_value>>5;
if(Fp[j]==0 || !(Fp[j] & (1<<(A_value-(j<<5)))) )
{
A[h]=A_value;
h++;
}
}
}
A_size=h;
}
if(F_minval<0)
{
ArrayInitialize(Fp, 0);
i=0; h=0;
while(i<F_size)
{
F_value=F[i];
if(F_value<0)
{
F_value=(~F_value)+1;
j=F_value>>5;
Fp[j]|=(1<<(F_value-(j<<5)));
}
i++;
}
for(i=0; i<A_size; i++)
{
A_value = A[i];
if(A_value<F_minval || A_value>-1)
{
A[h]=A_value;
h++;
}else
{
j=(~A_value+1)>>5;
if(Fp[j]==0 || !(Fp[j] & (1<<((~A_value+1)-(j<<5)))) )
{
A[h]=A_value;
h++;
}
}
}
A_size=h;
}
return (ArraySize(A)!=A_size ? ArrayResize(A, A_size):A_size);
}
Corrected a little bit the codeof nicholi shen
Now it meets the conditions of the problem and works for int arrays. I think this is the fastest option, taking into account that filter size F will be at least 6.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I think for a function to be universal, it needs to combine several different algorithms, tailored to the input data.
of course
I've finally found a way to do a quick hash kit.OK, a two-dimensional array e.g. [13][12]. How to delete the 7th line leaving the rest unchanged ?
Something like this
After optimisation.
Corrected a little bit the codeof nicholi shen
Now it meets the conditions of the problem and works for int arrays. I think this is the fastest option, taking into account that filter size F will be at least 6.