Read-Write cushioning design performance

Source: Internet
Author: User

Read-Write buffering

1. Using vectors as an internal implementation

2. Define the pre-interpolation area, the readable area, the post-interpolation area, with the dynamic integer subscript mark the position, where subscript satisfies 0<= readindex <= writeindex <= size ()

3. Define the size of the pre-insert at initialization, and the size of the back plug, such as Readindex = Writeindex = 8, size () = 1032 (8+1024)

4. The read and retrieve interfaces are provided, the former only reads and the latter reduces the readable area.

5. Question: What if the write area is not enough? 1. Dynamically allocate larger memory 2. Internal maneuvers

6. Question: What should I do if the front plug area becomes larger after continuous reading and writing? 1. When all the readable data is retrieve, the buffer is restored to the initial state 2. When allocating larger memory, change the front interpolation area to the initial size of 3. Internal maneuvers

Read-Write cushioning design performance

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.