In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what the data structure in C# is, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
1. Array (Array)
Arrays have the following characteristics:
The array is a linear structure and is stored continuously in memory.
The array must have the same element type.
Arrays can be accessed directly through the subscript.
The lookup speed of the array is very fast, and the speed of adding and deleting is slow.
The array length is specified when the array is initialized.
2. Dynamic array (ArrayList)
Dynamic arrays have the following characteristics:
The bottom layer of ArrayList is actually an array.
ArrayList does not have to specify a length when declaring, but dynamically increases or decreases the length based on the stored data.
ArrayList treats all elements as Object, so you can store elements of different data types.
When inserting and deleting an element, it moves the position of all elements after it. It is inefficient to insert or delete elements frequently. It is recommended to use LinkedList.
ArrayList is non-type safe, unpacking and boxing problems occur when inserting and deleting elements, which affects performance and is inefficient.
3. Generic List
Generic List has the following characteristics:
List is a generic class for ArrayList.
A generic List needs to specify a specific type at the time of declaration.
Generic List has no boxing and unboxing operations, so List is more efficient and type safe than ArrayList.
4. Two-way linked list (LinkedList)
Two-way linked lists have the following characteristics:
The space of the nodes in the linked list is discontinuous in memory, each space is called a node, and each node has a leading pointer and a post pointer pointing to the former node and the latter node, respectively. Therefore, the effect of adding and deleting elements to the linked list is high, only need to change the pointer to the corresponding node.
The search efficiency of linked list is low. Elements cannot be accessed by subscript when looking up, but can only be looked up sequentially by address from scratch.
5. Stack (Stack)
The stack has the following characteristics:
The stack is a first-in-first-out principle, in which the first inserted element is accessed last, and the last inserted element is accessed first.
Push enters the stack, Pop leaves the stack and returns the top element of the stack, and Peek returns only the top element of the stack.
6. Queue (linked list)
Linked lists have the following characteristics:
The linked list is a first-in, first-out principle, in which the first-in elements are accessed first, and the last-entered elements are accessed last.
Enqueue enters the queue, Dequeue leaves the queue and returns the column header element, and Peek returns only the column header element.
7. Dictionary (Dictionary)
Dictionaries have the following characteristics:
You need to specify the data types of key and value when creating a dictionary.
The value of key in the dictionary is unique, and the value of value may not be unique.
You can quickly find the corresponding value through key, which is fast, but consumes memory.
Usage scenarios for several common data structures Array can be considered when the number of elements to be processed is determined and subscripts need to be used for access, but List is recommended. ArrayList is not recommended and generic List is recommended. It is usually recommended when the number of elements that a generic List needs to deal with is uncertain. LiskedList linked list is suitable for situations where the number of elements is not fixed and nodes need to be added or decreased frequently, and it is efficient to add or decrease elements in linked lists. Queue queues are suitable for first-in, first-out situations. The Stack stack is suitable for first-in-first-out situations. Dictionary dictionaries are suitable for situations where key-value pair operations are required. The above is all the content of the article "what is the data structure in C#". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 228
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.