c # in several common data structures

Array (Array):
1, the array is stored in contiguous memory
2, must be the same type of the array element
3, the array can be directly accessed by the subscript
4, the speed of search and modify elements very quickly
5, the statement must specify the length of time
 
 
Dynamic array (ArrayList):
1, the bottom is actually an array of ArrayList
2, when a statement is not necessary to specify the length, dynamically increased or decreased in accordance with the stored data length
3, insert and delete an element, will move the location of all the elements after it inefficient, frequently recommended when inserting delete elements LinkedList
4, ArrayList will all elements as Object processing, it is possible to store different types of elements
5, ArrayList non-security type, and when inserting and removing elements will be unpacking and packing operation, consumption performance, inefficiency
 
 
Generic List:
1, List equivalence class is a generic ArrayList
2, need to specify the type when declaring generic
3, no unpacking packing operation, so in most cases higher than the List ArrayList efficient and type-safe
 
 
Doubly linked list (LinkedList):
1, the list in memory space is not continuous, each space called a node, each node address of the node there before and after it is connected, thus adding to the list and delete only need to change the element point to the address of the relevant node storage, high efficiency
2, can not find elements at the time mark visit, only to start from scratch in order to find the address, inefficient
 
 
Stack (Stack):
Last-out principle, the first element inserted last accessed, the last element inserted is the first visit
 
 
Queue (Queue):
FIFO principle, the first element inserted the first to be visited, the last element inserted last accessed
 
 
Dictionary (Dictionary):
1, you need to specify the type of key and value when creating the dictionary
2, the value of the dictionary key must be unique, value is not unique
3, can quickly find the corresponding value by key, fast speed, but consumes memory

Guess you like

Origin www.cnblogs.com/qingfenglin/p/12016276.html