This commit is contained in:
Ali
2020-01-17 19:33:47 +04:00
parent 9ac0e6a2bf
commit cae30133bc
12 changed files with 200 additions and 78 deletions

View File

@@ -181,7 +181,7 @@ public func mergeListsStableWithUpdates<T>(leftList: [T], rightList: [T], allUpd
return (removeIndices, insertItems, updatedIndices)
}
@inlinable
//@inlinable
public func mergeListsStableWithUpdates<T>(leftList: [T], rightList: [T], isLess: (T, T) -> Bool, isEqual: (T, T) -> Bool, getId: (T) -> AnyHashable, allUpdated: Bool = false) -> ([Int], [(Int, T, Int?)], [(Int, T, Int)]) {
var removeIndices: [Int] = []
var insertItems: [(Int, T, Int?)] = []
@@ -207,6 +207,25 @@ public func mergeListsStableWithUpdates<T>(leftList: [T], rightList: [T], isLess
}
#endif
var leftStableIds: [AnyHashable] = []
var rightStableIds: [AnyHashable] = []
for item in leftList {
leftStableIds.append(getId(item))
}
for item in rightList {
rightStableIds.append(getId(item))
}
if Set(leftStableIds) == Set(rightStableIds) && leftStableIds != rightStableIds {
/*var i = 0
var j = 0
while true {
if getId(leftList[i]) != getId(rightList[i]) {
}
}*/
print("order changed")
}
var currentList = leftList
var i = 0