Guard against the sequential traps of Dictionary and SortedDictionary

Source: Internet
Author: User

/*
We know that the traversal order of the Dictionary is the same as that of the Add command, unlike the HashTable command. Therefore, I want to make a decision based on the sequential consistency feature of the Dictionary command, for a Queue with a fixed size of 400, if more than 400 elements are involved, Remove old data and retain new data. Why do I not need Queue because it does not have the ContainsKey search function, because I need to use a key to repeat.
When my program runs for a period of time, a logic problem occurs. Originally, my program logic was 400, and then the old data that was added most was deleted, but the last added data was deleted, when traversal is performed, the order is disordered, and it is not the added program. It is found that the dictionary object cannot be consistent with the program, and the consistency of the Remove sequence cannot be ensured.
*/




SortedDictionary <,> testdict = SortedDictionary <,>, (KeyValuePair <,> kv <,> testdict = Dictionary <,>, (KeyValuePair <,> kv

 

 

 

 

 

 

Related Article

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.