在LinkedList<>中排序 [英] Sorting in LinkedList<>
问题描述
嗨。
我主要用C ++编程,而且我不熟悉C#和.NET。在我上一个
项目中,我开始使用LinkedList<突然发现,不能
找到一种方法对它进行排序。这是否意味着我必须实现排序
LinkedList<我自己?
提前谢谢
Martin
Hi.
Mostly I program in C++, and I''m not fluent in C# and .NET. In my last
project I began to use LinkedList<and suddenly noticed that can''t
find a way to sort it. Does it mean I must implement sorting for
LinkedList<myself?
Thanks in advance
Martin
推荐答案
" martin-g" < ma ****** @ mail.ruwrote in message
news:11 ********************** @ f1g2000cwa .googlegro ups.com ...
"martin-g" <ma******@mail.ruwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
嗨。
我主要用C ++编程,我不是精通C#和.NET。在我上一个
项目中,我开始使用LinkedList<突然发现,不能
找到一种方法对它进行排序。这是否意味着我必须实现排序
LinkedList<我自己?
提前谢谢
Martin
Hi.
Mostly I program in C++, and I''m not fluent in C# and .NET. In my last
project I began to use LinkedList<and suddenly noticed that can''t
find a way to sort it. Does it mean I must implement sorting for
LinkedList<myself?
Thanks in advance
Martin
所以它会出现。
也许这篇文章会对你有所帮助:
http://msdn2.microsoft.com/en-us/library/6tc79sx1.aspx
pvdg42写道:
pvdg42 wrote:
所以它会出现。
也许这篇文章对你有所帮助:
http://msdn2.microsoft.com/en-us/library/6tc79sx1.aspx
感谢您的回答。这真的很疯狂......翻阅文章
我最终无法选择我需要的收藏类。在
上我想要一个项目在任何位置以恒定时间添加到容器中
,所以必须使用LinkeList<>。另一方面,我想
对容器进行排序,所以我必须使用List<>。 FCL真的很奇怪
集装箱组织......只有现在我明白了:我非常喜欢STL ......
Thank you for answer. That''s really wild... Looking through the article
I couldn''t eventually select the collection class of my need. On the
one hand I want an item to be added to the container at constant time
at any position, so must use LinkeList<>. On the other hand I want to
sort the container, so I must use List<>. FCL has really strange
container organization... Only now I understood: I love STL very much...
martin -g写道:
martin-g wrote:
pvdg42写道:
pvdg42 wrote:
所以它会出现。
也许这篇文章对你有帮助:
http://msdn2.microsoft.com/en-us/library/6tc79sx1.aspx
感谢您的回答。这真的很疯狂......翻阅文章
我最终无法选择我需要的收藏类。在
上我想要一个项目在任何位置以恒定时间添加到容器中
,所以必须使用LinkeList<>。另一方面,我想
对容器进行排序,所以我必须使用List<>。 FCL真的很奇怪
集装箱组织......只有现在我明白了:我非常喜欢STL ...
Thank you for answer. That''s really wild... Looking through the article
I couldn''t eventually select the collection class of my need. On the
one hand I want an item to be added to the container at constant time
at any position, so must use LinkeList<>. On the other hand I want to
sort the container, so I must use List<>. FCL has really strange
container organization... Only now I understood: I love STL very much...
所以你想要不变时间插入和对
集合进行排序的能力。 List<集合听起来很不错。
插入通常是O(1),你可以调用Sort方法来对集合进行排序
。你看过SortedDictionary了吗?插入
有点慢,但是这些项目总是按顺序存储所以
不需要执行单独的排序操作。
Brian
So you want constant time insertions and the ability to sort the
collection. The List<collection sounds like a good match.
Insertions are usually O(1) and you can call the Sort method to sort
the collection. Have you looked at SortedDictionary yet? Insertions
are a bit slower, but the items are always stored in order so there''s
no need to perform a separate sort operation.
Brian
这篇关于在LinkedList<>中排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!