generative modeling for Rhino
Permalink Reply by Dedackelzucht on March 31, 2011 at 12:41am 
Hi Paolo,
see attached. It's a bit smaller (and I think quite a bit faster, especially on large lists). I added comments to the code, but here it is without:
Dim lut As New SortedDictionary(Of Double, Boolean)
Dim result As New List(Of Double)
For Each value As Double In Values
If (lut.ContainsKey(value)) Then Continue For
result.Add(value)
lut.Add(value, True)
Next
A = result
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Permalink Reply by Firat Aydin on April 25, 2013 at 2:03am what to do for string duplicates?

Dim lut As New SortedDictionary(Of String, Boolean)
Dim result As New List(Of String)
You can use any type you want as long as it provides it's own CompareTo method. If it doesn't, then you'll have to provide the SortedDictionary with a custom delegate which performs the comparison.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David
(it's always a pleasure learning from the master)
Added by Mgeorgio 0 Comments 0 Likes
Added by Mgeorgio 0 Comments 0 Likes
© 2013 Created by Scott Davidson.
Powered by