Click here to Skip to main content
15,867,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: LinkedList since .NET 2 Pin
David198714-Apr-11 23:10
David198714-Apr-11 23:10 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:12
devvvy14-Apr-11 23:12 
GeneralRe: LinkedList since .NET 2 Pin
David198714-Apr-11 23:44
David198714-Apr-11 23:44 
GeneralRe: LinkedList since .NET 2 Pin
devvvy16-Apr-11 16:53
devvvy16-Apr-11 16:53 
AnswerRe: LinkedList since .NET 2 Pin
PIEBALDconsult14-Apr-11 2:59
mvePIEBALDconsult14-Apr-11 2:59 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:11
devvvy14-Apr-11 23:11 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:43
devvvy14-Apr-11 23:43 
AnswerRe: LinkedList since .NET 2 Pin
Alan Balkany14-Apr-11 4:13
Alan Balkany14-Apr-11 4:13 
"Does anybody has a good scenario as an example where they'd need LinkedList?"


It's useful when you don't know the size you'll need in advance, you're doing mostly sequential processing, and want fast performance. Insertions/deletions in the middle are fast. Its drawbacks are:

1. Memory overhead from pointers,
2. It's slow for randomly accessing elements in the middle, i.e. the nth element. Sorting is very slow.
3. No locality of reference, i.e. when you access element n, element n + 1 probably isn't in the cache, as it would be with an array or List.

You could use a List, which has fast indexed access (nth element) but there are some drawbacks:

1. When you exceed its initial allocation, it copies the WHOLE list to a new array. This is slow.
2. The new array is double the size of the previous one, so you may end up allocating twice the storage you need.
3. Insertions and deletions in the middle are slow, since many elements have to be moved.

You have to use the right tool for the job.
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:03
devvvy14-Apr-11 23:03 
GeneralRe: LinkedList since .NET 2 Pin
Pete O'Hanlon14-Apr-11 23:37
subeditorPete O'Hanlon14-Apr-11 23:37 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:42
devvvy14-Apr-11 23:42 
GeneralRe: LinkedList since .NET 2 Pin
Alan Balkany15-Apr-11 3:24
Alan Balkany15-Apr-11 3:24 
GeneralRe: LinkedList since .NET 2 Pin
devvvy16-Apr-11 16:50
devvvy16-Apr-11 16:50 
GeneralRe: LinkedList since .NET 2 Pin
Alan Balkany18-Apr-11 4:07
Alan Balkany18-Apr-11 4:07 
QuestionApplication Crashes during AppDomain.Unload [modified] Pin
Benny_Lava13-Apr-11 3:44
Benny_Lava13-Apr-11 3:44 
AnswerRe: Application Crashes during AppDomain.Unload Pin
gavindon13-Apr-11 3:56
gavindon13-Apr-11 3:56 
GeneralRe: Application Crashes during AppDomain.Unload Pin
Benny_Lava13-Apr-11 9:41
Benny_Lava13-Apr-11 9:41 
AnswerRe: Application Crashes during AppDomain.Unload Pin
Not Active13-Apr-11 3:57
mentorNot Active13-Apr-11 3:57 
GeneralRe: Application Crashes during AppDomain.Unload Pin
Benny_Lava13-Apr-11 9:25
Benny_Lava13-Apr-11 9:25 
AnswerRe: Application Crashes during AppDomain.Unload Pin
BobJanova13-Apr-11 6:18
BobJanova13-Apr-11 6:18 
GeneralRe: Application Crashes during AppDomain.Unload Pin
Benny_Lava13-Apr-11 9:38
Benny_Lava13-Apr-11 9:38 
GeneralRe: Application Crashes during AppDomain.Unload Pin
BobJanova13-Apr-11 10:57
BobJanova13-Apr-11 10:57 
GeneralRe: Application Crashes during AppDomain.Unload Pin
Benny_Lava13-Apr-11 22:06
Benny_Lava13-Apr-11 22:06 
AnswerRe: Application Crashes during AppDomain.Unload Pin
jschell13-Apr-11 8:46
jschell13-Apr-11 8:46 
Questionrefreshing second combo by first not working Pin
uglyeyes13-Apr-11 1:11
uglyeyes13-Apr-11 1:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.