iphone - comparing 2 arrays ,remove the elements with same field -



This is my problem, I have 5000 arrays, I want to remove those elements in array4999 which have the same name To Array5000, then add array5000 comes out with a new array, says newArray1 again remove the same name elements from array4998 and newArray2 comes out. Iteratively, until all 5000 arrays are made with filters and leaves only a new array, there is no duplicate name in it.

What I am planning to do is as an example below, the head of the unit objects says:

  @interface Entity: NSObject {NSString * firstName; NSString * lastName; Nsnm * nid; Object1; . . . ObjectN}  

I want to compare those two arrays to three main fields: first name , lastname and nid (I do not care about other areas). If the elements in array5000 and array4999 are the same in these 3 fields, then remove the related elements in array4999 before adding the array to 5 99. As a result, New York 1 should look like an example below:

  array5000 = {"tom", "jackson", 235, ....}, {"dick", "martin" , 360, "Martin", "Mounson", 125, ....}, {"Dick", "Martin", ...), {"Jimmy", "Green", 568, ...} array4999 = "Junk", "360", "Creative", "360", "360", "Green", 568, ...} {"John", "Mosson", 125, ...};  

Let me have a method - (zero) deleted object input: (NSArray *) Other arrays that got close to my needs, but this method is Other arrays are then those elements are completely identical to the related element in the receiver. For me, if I have the first name , lastName and the nid fields are the same, then I want to remove the elements I have array4999 with elements of the same name I want to filter it, then add it to array5000 to get it NewArray1. Next, remove array4498 filtering elements similar to the new array 1, then merge NewArray1 and array4998 to get NewArray2. Filter all the 5000 arrays, by descending, one by one. Since performance is an issue, can anyone give me some ideas on my problem? Some code samples will be appreciated.
Thanks in advance.

The simplest way to use nested loop is as follows:

  NSMutableArray * Array3 = [[array1 mutableCopy] autorelease]; (In unit 2 for unit 2) {BOOL noMatchFound = TRUE; (Array 1 in entity * unit 1) {if ([entity1.firstNameEqual: entity2.firstName] & amp; [entity1.lastNameEqual: entity2.lastName] & amp; amp; amp; amp; amp; unit1. Equal is: entity2 Nid] {NoMatchFound = FALSE; breakdown;}} If (no matchfound) {[array3 addObject: entity2]; As a result in array3, now all the basic bodies from array1 will be included, as well as any units from array 2 which are not equal to  First name ,  last code  and  nid  properties. 

Note that this code assumes that entity Definitions in @property in the class are all your important For full areas.


Comments