Re: Sorted Dictionary / List woes.
"Nassar, Anthony" <[email protected]> Tue, 13 Nov 2007 11:18:10 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Ryan's suggestion is good. Only you know if 1, the list needs to *stay*
sorted by timestamp (I can't imagine why that would be the case), and 2,
if there are concurrency issues.
public class MyDictionary : IDictionary<long, MessageInfo>
{
private Dictionary<long, MessageInfo> _impl = new
Dictionary<long, MessageInfo>();
public IEnumerable<MessageInfo> GetChronologically()
{
List<MessageInfo> sorted = new
List<MessageInfo>(_impl.Values);
sorted.Sort(
delegate(MessageInfo left, MessageInfo right)
{
return
left._dateTime.CompareTo(right._dateTime);
});
return sorted;
}
...