Skip to main content
6 events
when toggle format what by license comment
Nov 12, 2019 at 19:52 comment added Eric Lippert @WimtenBrink: List<T> has a binary search method on it. docs.microsoft.com/en-us/dotnet/api/…
Nov 12, 2019 at 19:45 comment added Wim ten Brink But it would mean implementing my own binary search. Done that a gazillion times already so I rather reuse an existing one. The SortedSet might be an option...
Nov 12, 2019 at 19:03 comment added Eric Lippert @WimtenBrink: A SortedList maintains the sort property for you, but you don't need that; you are already ensuring that the list is always sorted by only appending larger items after smaller.
Nov 12, 2019 at 18:58 comment added Brian @WimtenBrink: A sorted List<T> of primes is fine. BinarySearch is a member of List<T>.
Nov 12, 2019 at 3:28 comment added Wim ten Brink Good points! You're right, an EnsureUpTo() method would be better. As for the list being sorted... I had not really considered that, as it's a side effect. A binary search would indeed be better. But a SortedList<> requires a key and value, so maybe I need a SortedSet for Primes?
Nov 11, 2019 at 23:33 history answered Eric Lippert CC BY-SA 4.0