Home > Back-end >  How to delete the duplicate content in the TList?
How to delete the duplicate content in the TList?

Time:10-07

Now I have a lot of related to coordinate the TList of content, there are about 300000 of them, such as:
The 10-10-1
The 10-10-2
The 10-10-3
The 20-10-2
The 20-10-1
The 10-10-4
Is in front of x and y coordinates, and the last is the coordinates of the tag, I now need to coordinate the same keep only the last one, after processing the result is as follows:
The 20-10-1
The 10-10-4
Who can help me!!!!!!

CodePudding user response:

After traversal Tlist then sort Tlist then from interception of x and Y determine whether current. If x and Y is the same as the front. Agree, delete this is what I want

CodePudding user response:

Utilize Tstringlist can directly sequenced

CodePudding user response:

The first four digits, regarded as the index of 0000-9999,
Do with another TList records,

In the original TList from first to last, take out four into index,
Set up the new List [Index]='A'

Finally, the new List from 0-9999 to run A circle, every value is' A 'is everything,

CodePudding user response:

I have too many contents, after traversal computing

CodePudding user response:

I gave the solution, just a second traversal, is a fast algorithm,
If I say yes, with sorting will be slower,

In fact, the more is the right thing when data is processed by the new List I above scheme,
It is fast, no traversal problem,

CodePudding user response:

Sorting itself is the traversal
But only 300000, what computer operations don't come here,,,

CodePudding user response:

1. The traversal, delete the same
2. Don't want to write code, but keep the data to the database table, use the SQL processing

CodePudding user response:

Novice a, or talk about?
30 w to traversal or time consuming, LS said, in a database, so efficient point,
Personal feel or good algorithm, then can solve many problems

CodePudding user response:

One, in the database;
Second, introduce the ID column, the introduction of a unique identifier to each data;
Three, your this a field split in two fields, the split into 10-10-10-10-1, 1
Four, with the GROUP BY HAVING the COUNT function and find out all duplicate data maximum ID (don't know how to use baidu to check),
5, remove the biggest ID data;
Six, synthesize two fields a field,

CodePudding user response:

refer to 6th floor sololie response:
sort itself is the traversal
But only 300000, what computer operations don't come here,,,


Sorting algorithm is proven, generally must be faster than they traverse,,,,,,,

CodePudding user response:

After traversal in the hash table storage, repeat the project will be very easy to find,

CodePudding user response:

 Const 
PiXMax=4000;//assume X Max
PiYMax=3000;//assume that a maximum Y
Type
TXYList=array [0.. piXMax * piYMax - 1] of Byte;
PXYList=^ TXYList;

The function SplitStr (Const sLine: String; Var y: integer) : Boolean;
Var
I, x, y: integer;
P: PChar;
The begin
Result:=False;
If sLine="' then the exit;
P:=Pointer (sLine);
X:=1;
Y:=1;
For I:=0 to Length do the begin (sLine) - 1
If P='-' [I] then begin
If x<0 then: x=I
The else begin
Y:=I;
Break;
end;
end;
end;
If y<=0 then the exit;
If TryStrToInt (Copy (sLine, 1, x), x, y) then the begin
Xy:=y * piYMax;
If TryStrToInt (Copy (sLine, x + 2, y - x - 1), y) then the begin
Xy:=y + y;
Result:=yend;
end;
end;

Procedure RemoveXYRep (InList OutList: TStringList);
Var
I, x, y: integer;
The List: PXYList;
SLine: String;
The begin
GetMem (List, SizeOf (List ^));
^ ^ FillChar (List, SizeOf (List), 0).
OutList. BeginUpdate;
OutList. The Clear;
For I:=InList. Downto Count - 1 0 do after the begin//from search
SLine:=InList Strings [I];
If SplitStr (sLine, x, y) then the begin//ict lead
If the List [y]=0 then the begin//if the x, y, there is no
The List [y] :=1;//set to exist
OutList. Add (sLine);//added to the OutList, from backward
end;
end;
end;
//an inverted order
Xy:=OutList. Count - 1;
For I:=0 to OutList. Count DIV do begin 2-1
OutList. Exchange (I, xy - I);
end;
OutList. EndUpdate;
FreeMem (List);
end;
  • Related