Departure dynamic Array V2.0

Source: Internet
Author: User

Brief introduction

The management of large amounts of data is the heart of many programmers, and it is hard to find a table that is fast, efficient, and supports large scale data. On the basis of the 1.0 version, the departure cost has written down this enhanced data insertion and deletion of the revised version, departure dynamic array is a powerful list-shape data management chain, which can easily realize the random insertion, deletion and modification of large amount of data, and it is also characterized by extremely fast speed and high memory utilization.

A lot of data management must occupy a lot of memory space, if the size of the data occupied by varying with the various conditions, we can not use the array to manage the data (the truth is not much to say), when we need a dynamic array. MFC provides a good dynamic array class CArray, for a small amount of data, the use of CArray is useful enough, but for a large number of data (10W level) It is powerless, because its essence is an array, but the commonly used inserts, deletes and other operations carried out a complex packaging. In order to solve this problem, the departure dynamic array of the linked list and the array of ingenious combination of the advantages of high speed random index of the array, but also the data volume of the list of flexible and changeable characteristics.

Working principle

Departure dynamic array of data structures such as figure (This is the 1.0 version of the schematic, version 2.0 in the node to indicate the current data segment has been used in the space variable). To solve the problem of dynamic storage of large amount of data, departure dynamic array of data in the list of nodes stored in the node, each paragraph can hold a certain amount of data, if the amount of data increased, the allocation of a new segment in memory, if the data to reduce the release of free data segments, thus effectively solve the problem. Compared to version 1.0, the 2.0 version introduces the use of space and the total free space of two variables in each node, after this processing, the data in the insert deletion will no longer need to move the data in the entire array and only need to do a simple processing of the target data segment.

Inserting data

If the target segment has an idle location, you only need to defragment and insert the data, and if the target segment has no free space, the departure Dynamic data automatically requests a new piece of data in memory and links the data segment to the list.

Delete data

After the target segment is found, the target data is deleted from the target data segment, and if only the target data is included in the target segment, the departure dynamic array automatically deletes the target segment and maintains the integrity of the linked list.

Add data

Check the last segment of data, and if there is space, no more allocations, no data segments for subscribe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.