Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Prasanta_Prince15-Apr-11 6:34
Prasanta_Prince15-Apr-11 6:34 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
#realJSOP14-Apr-11 2:01
professional#realJSOP14-Apr-11 2:01 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
PIEBALDconsult14-Apr-11 2:57
mvePIEBALDconsult14-Apr-11 2:57 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Luc Pattyn14-Apr-11 4:15
sitebuilderLuc Pattyn14-Apr-11 4:15 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Keith Barrow14-Apr-11 4:31
professionalKeith Barrow14-Apr-11 4:31 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
Luc Pattyn14-Apr-11 4:17
sitebuilderLuc Pattyn14-Apr-11 4:17 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
Keith Barrow14-Apr-11 4:29
professionalKeith Barrow14-Apr-11 4:29 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Pete O'Hanlon14-Apr-11 5:28
mvePete O'Hanlon14-Apr-11 5:28 
QuestionLinkedList<T> since .NET 2 [modified] Pin
devvvy13-Apr-11 15:55
devvvy13-Apr-11 15:55 
AnswerRe: LinkedList since .NET 2 Pin
OriginalGriff14-Apr-11 0:10
mveOriginalGriff14-Apr-11 0:10 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 22:59
devvvy14-Apr-11 22:59 
GeneralRe: LinkedList since .NET 2 Pin
OriginalGriff14-Apr-11 23:07
mveOriginalGriff14-Apr-11 23:07 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:13
devvvy14-Apr-11 23:13 
GeneralRe: LinkedList since .NET 2 Pin
OriginalGriff14-Apr-11 23:28
mveOriginalGriff14-Apr-11 23:28 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:38
devvvy14-Apr-11 23:38 
GeneralRe: LinkedList since .NET 2 Pin
David198714-Apr-11 0:35
David198714-Apr-11 0:35 
GeneralRe: LinkedList since .NET 2 Pin
devvvy14-Apr-11 23:00
devvvy14-Apr-11 23:00 
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.

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.