Linked lists in C#
LinkedList<T>is a doubly linked list, where one element references the next and the previous one.
Advantage of a linked list is that if items are inserted in the middle of a list, the linked list is very fast. When an item is inserted, only the Next reference of the previous item and the Previous reference of thenext item must be changed to reference the inserted item. With the List<T>class, when an element is inserted all following elements must be moved.
Disadvantage with linked lists. Items of linked lists can be accessed onlyone after the other. It takes a long time to find an item that’s somewhere in the middle or at the end ofthe list.A linked list cannot just store the items inside the list; together with every item, the linked list must haveinformation about the next and previous items.
The LinkedList<T>class itself defines members to access the first (First) and last (Last) item of the list, to insert items at specific positions (AddAfter(), AddBefore(), AddFirst(), AddLast()), to remove items
from specific positions (Remove(), RemoveFirst(), RemoveLast()), and to find elements where the search either starts from the begin (Find()) or the end (FindLast()) of the list.
Дата добавления: 2015-09-18 | Просмотры: 542 | Нарушение авторских прав
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
|