I need to search a child collection based on a property value and return the childs index number. I'm currently using this: Public Function FindChildIndex(ByVal childGuid As Guid) As Integer This doesn't work so well when the collection gets large... I'm looking for a better way to implement this, any suggestions? Thanks!
For i As Integer = 0 To Me.Count - 1
If Me.Item(i).ToString.Equals(childGuid.ToString) Then
Return i
End If
Next
Return -1
End Function
How large can your collection get?
You should not use the ToString method - try rather the IComparable.CompareTo method.
That may speed thing up a little.
If childGuid.CompareTo(Me.Item(i)) = 0 Then
With really large collections you could look into using some indexing library, f.ex http://i4o.codeplex.com and I'm sure there are others as well.
750,000 - 1,000,000 records. It's not typical, but they do exist out there.
I've glanced at the indexing library, it looks helpful. Thanks!
Copyright (c) Marimer LLC