C#中的LinkedList使用它们的好例子 [英] LinkedList in C# good case to use them

查看:79
本文介绍了C#中的LinkedList使用它们的好例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在技术评审中我被问到链接列表是什么,我用学术来回答

定义。然后一个人问我如何在C#中实现一个

链表,以及链表的好例子。

我想不出任何.NET类实现真正的链接列表(我不认为
认为有任何)。但是,我猜一个人可以实现他们自己的链表。

我不能想到一个好的情况,但绝对必要的是

。我的意思是System.Collections提供了足够的实现来存储

并以任何你想象的方式访问数据。

是否公平地说链表是C天之前的事情框架

班级?

Hi,

I was asked at the tech screening what the linked list was which I answered
with "academic" definition. Then a guy asked me how I would implement a
linked list in C# and what would be a good case for linked list.
I could not think of any .NET class that implement true linked list (I don''t
think there is any). But, I guess one could implement their own linked list.
I couldn''t think of a good case when it would be absolutely necessary
though. I mean System.Collections provides enough implementations to store
and access data any way you could imagine.
Is it fair to say that linked list is a thing of C days before framework
classes?

推荐答案

LP,


不,我不喜欢不认为这是演员。一般来说,就我的目的而言,当您必须执行的大多数操作是通过列表遍历时,链接

列表是好的,以及向末尾添加元素或到

开头。然而,对于像

排序或搜索内容这样的东西来说,它们总是很糟糕。


这完全取决于你,以及你面临的情况。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" LP" < lp@a.com>在消息中写道

news:eW ************** @ TK2MSFTNGP15.phx.gbl ...
LP,

No, I don''t think this is the cast. Generally, for my purposes, linked
lists are good when the majority of operations you have to perform are
traversals through the list, as well as adding elements to the end or to the
beginning. However, they absolutely suck as the grow larger for things like
sorting, or searching for content.

It''s all up to you, and the situation you are faced with.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"LP" <lp@a.com> wrote in message
news:eW**************@TK2MSFTNGP15.phx.gbl...

在技术筛选中,我被问到链接列表是什么,我用学术回答了
。定义。然后一个人问我如何在C#中实现一个
链接列表以及链接列表的好例子。
我想不出任何实现真正链表的.NET类(我<不要认为有任何东西。但是,我猜一个人可以实现他们自己的联系
列表。
虽然这是绝对必要的,但我想不出一个好的案例。我的意思是System.Collections提供了足够的实现来以任何你想象的方式存储和访问数据。
在框架
类之前,链表是否是C天是否公平?
Hi,

I was asked at the tech screening what the linked list was which I
answered
with "academic" definition. Then a guy asked me how I would implement a
linked list in C# and what would be a good case for linked list.
I could not think of any .NET class that implement true linked list (I
don''t
think there is any). But, I guess one could implement their own linked
list.
I couldn''t think of a good case when it would be absolutely necessary
though. I mean System.Collections provides enough implementations to store
and access data any way you could imagine.
Is it fair to say that linked list is a thing of C days before framework
classes?



可以使用ArrayList轻松完成。


" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>写在

消息新闻:u6 ************** @ tk2msftngp13.phx.gbl ...
that could be easily done with an ArrayList.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:u6**************@tk2msftngp13.phx.gbl...
LP,
不,我不认为这是演员。一般来说,对于我的目的,
链接列表是好的,当你必须执行的大多数操作是遍历列表,以及添加元素到结尾或开始时
。然而,他们绝对会因为分类或搜索内容而变得越来越大。

这完全取决于你,以及你所面临的情况。 />
希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

LP < lp@a.com>在消息中写道
新闻:eW ************** @ TK2MSFTNGP15.phx.gbl ...
LP,

No, I don''t think this is the cast. Generally, for my purposes, linked lists are good when the majority of operations you have to perform are
traversals through the list, as well as adding elements to the end or to the beginning. However, they absolutely suck as the grow larger for things like sorting, or searching for content.

It''s all up to you, and the situation you are faced with.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"LP" <lp@a.com> wrote in message
news:eW**************@TK2MSFTNGP15.phx.gbl...

我在技术筛选时被问到链接列表是什么,我用学术回答了
。定义。然后一个人问我如何在C#中实现一个
链接列表以及链接列表的好例子。
我想不出任何实现真正链表的.NET类(我<不要认为有任何东西。但是,我猜一个人可以实现他们自己的联系
列表。
虽然这是绝对必要的,但我想不出一个好的案例。我的意思是System.Collections提供足够的实现来
存储并以你能想象的方式访问数据。
在框架
类之前,链表是C天是否公平?
Hi,

I was asked at the tech screening what the linked list was which I
answered
with "academic" definition. Then a guy asked me how I would implement a
linked list in C# and what would be a good case for linked list.
I could not think of any .NET class that implement true linked list (I
don''t
think there is any). But, I guess one could implement their own linked
list.
I couldn''t think of a good case when it would be absolutely necessary
though. I mean System.Collections provides enough implementations to store and access data any way you could imagine.
Is it fair to say that linked list is a thing of C days before framework
classes?






当列表中的项目数量时链接列表很好是小的

因此循环整个列表比通过另一种方法查找

单项更快(即,在排序列表上的二进制搜索

或哈希表的哈希码生成。


System.Collections.Specialized.ListDictionary实现链接列表

用于此类场合。


System.Collections.Specialized.HybridDictionary是一个包装类

,当列表

变大时,它使用LinkedList表示小列表和Hashtable 8项。但是,它在

包装器中有一些开销,所以如果你提前知道你的列表大小是多少,那么只需使用适当的列表就可以了。 (混合型适用于案例

,其中大部分时间列表将非常小但是有一个

的机会,列表可能会变得更大)。


另外一些类在内部使用链接列表,例如

MulticastDelegate和Exception。

不确定面试官想要听到什么,但是当我'已经问过

类似问题的受访者(只有当他们提出

数据结构时)我通常想听到他们永远不会写的

一个人自己。但是,每个面试官都可能正在寻找一个完全不同的答案,所以这不是一个很好的问题(当然我的

意见)。


祝你好运,


Sam

星期一,2005年3月21日11:05:46 -0500,LP < lp@a.com>写道:

Linked Lists are good when the number of items in the list are small
and thus looping through the entire list is faster than looking up a
single item through another method (i.e., binary search on sorted list
or generation of hashcode for hashtable).

System.Collections.Specialized.ListDictionary implements a Linked List
for such occasions.

System.Collections.Specialized.HybridDictionary is a wrapper class
that uses a LinkedList for small lists and a Hashtable when the list
gets larger than 8 items. However, it has some overhead in the
wrapper so if you know ahead of time what size your list will be, it''s
better to just use the appropriate list (the hybrid is good for cases
where most of the time the list will be very small but there is a
chance the list could grow bigger).

Also some classes use linked lists internally such as
MulticastDelegate and Exception.
Not sure what the interviewer would want to hear but when I''ve asked
similar questions of interviewees (which is only when they bring up
data structures) I usually want to hear that they would never write
one themselves. However, each interviewer could be looking for a
totally different answer, so it''s not really a good question (my
opinion of course).

Best regards,

Sam
On Mon, 21 Mar 2005 11:05:46 -0500, "LP" <lp@a.com> wrote:


在技术筛选中,我被问到链接列表是什么,我用学术回答了
定义。然后一个人问我如何在C#中实现一个
链接列表以及链接列表的好例子。
我想不出任何实现真正链表的.NET类(我不知道't
认为有任何)。但是,我想有人可以实现他们自己的链表。
虽然这绝对是必要的,但我想不出一个好的案例。我的意思是System.Collections提供了足够的实现来以任何你想象的方式存储和访问数据。
在框架
类之前,链表是否是C天是否公平?
Hi,

I was asked at the tech screening what the linked list was which I answered
with "academic" definition. Then a guy asked me how I would implement a
linked list in C# and what would be a good case for linked list.
I could not think of any .NET class that implement true linked list (I don''t
think there is any). But, I guess one could implement their own linked list.
I couldn''t think of a good case when it would be absolutely necessary
though. I mean System.Collections provides enough implementations to store
and access data any way you could imagine.
Is it fair to say that linked list is a thing of C days before framework
classes?




B-Line现在正在招聘一个华盛顿特区的VB.NET

开发者用于WinForms + WebServices职位。

找到中级到高级开发人员。获取

信息或将电子邮件简历应用于

sam_blinex_com。



B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.


这篇关于C#中的LinkedList使用它们的好例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆