Problem solving-definition and use of composite inspection items and composite inspection items
======================================Copyright Notice======================================
Copyright Disclaimer: This article is the original article of the blogger and cannot be reproduced without permission.
Please contact me through "contact email (wlsandwho@foxmail.com)" in the announcement on the right
Do not use academic references without the author's authorization.
Do not use commercial publishing, commercial printing, commercial references, or other commercial purposes without the author's authorization.
This article is occasionally revised and improved. To ensure that the content is correct, we recommend that you read it in the original article. <-------- One day I always want to create a template to kill this potato.
Link: http://www.cnblogs.com/wlsandwho/p/4736084.html
Shame wall: http://www.cnblogs.com/wlsandwho/p/4206472.html
========================================================== ====================================
This article is based on STL containers and cannot target "HelloWorld" readers.
========================================================== ====================================
Because many technical groups are added, some people often ask some strange questions. If you have time, you may think about it yourself and simulate the practice.
========================================================== ====================================
Let's first explain why this solution is available:
Assume that a project is called ABC,
It is composed of three sub-projects, A, B, and C,
Sub-project A has two detection rules: "+" is an exception, and "-" is normal,
Sub-Project B has three detection rules: "+" indicates mild abnormality, "++" indicates moderate abnormality, "++" indicates severe abnormality, and "-" indicates normal,
Sub-project C has two detection rules: "+" is an exception and "-" is normal.
The question is: how to organize the composition of this project?
How can I organize subitem detection rules?
What should I do if I add another project called AC (composed of A and C? Or how can I add an ABCD Project (A, B, C, and D?
This is what we will talk about in this article.
========================================================== ====================================
First think about it and then look at my analysis. After all, some things are very important. In case you have a better way.
========================================================== ====================================
In fact, this article does not have any technical content, but it is important to think about it.
============================================== Small advertisement ========== ======================================
Seeking for work
Some Skills: Windows platform, VC ++, MFC, core programming, SQL Server,
Expected position: Technical Management,
Expected location: Qingdao hi-tech zone.
(Do not do C #, because C # is not in the sub-skill Tree "MASM => C/C ++ => VC ++ => C ++/CLI .)
========================================================== ====================================
Obviously, a detailed analysis is required. After all, some sub-projects will appear in different projects, and modifications to them should be affected by synchronization-it is best to store only one copy.
========================================================== ====================================
Start with the sub-project.
Sub-Projects have several conditions and results
For example
A can be composed of normal, abnormal, and invalid, or be composed of normal, mild, moderate, severe, or invalid.
Then, the subitem model must be changeable and unlimited.
Let's take a closer look at it. Severe exceptions are severe exceptions. There is no re-division of the so-called "severe exceptions 1", "severe exceptions 2", and "severe exceptions 3,
That is to say, each condition Result of a subitem is an inseparable element and cannot be repeated.
So
Reference Value -- result
Map is used to store all judgment criteria: map <reference value, result>.
Such a map represents the criteria for judging anonymous subitems. Only one criterion is known, but not the subitem.
Because a sub-project corresponds to a set of judgment criteria, that is
Sub-project name -- map <reference value, result>,
In this way, all information about a subitem is displayed.
The following structure represents the set of several sub-projects.
Map <sub-project name, map <reference value, result>
========================================================== ====================================
View the project again
Project ABC contains sub-project A, Sub-Project B, and Sub-Project C. Therefore, A project corresponds to multiple sub-projects.
Project name -- map <sub-project name, map <reference value, result>
The following structure indicates the detailed information of all projects, including the sub-projects of the project, the detection rules of the corresponding sub-projects, and the details of the detection rules.
Map <project name, map <sub-project name, map <reference value, result>
========================================================== ====================================
The simple analysis is here.
The analysis result is:
Map <project name, map <sub-project name, map <reference value, result>
However, if you use it like this, everyone will go crazy. Access to the inner layer will scare people. And the compilation information on VC ++ is not good-looking.
(I am sure anyone who has used it has said yes, but I don't believe that I can do it myself. Whether you try it or not, I tried it anyway .)
Therefore, you need to split it properly.
========================================================== ====================================
Proper Information Redundancy is acceptable. A small amount of redundancy can be used to make the program readable and simplified.
The splitting process is to simplify the complex structure above.
========================================================== ====================================
Split map <project name, map <sub-project name, map <reference value, result>
Multimap <project name, subproject Name>
First, remove a layer of map to facilitate project name-sub-project name access. Add a set to assist the multimap statistics project name,
After all, multimap cannot easily retrieve the exact number of keys. (You can also leave it empty .)
(Another way is to split it into map <project name, set <sub-project name>, depending on your mood .)
Splitting outer map is actually very important. Only in this way can we reuse all the information of a subitem.
Although this is actually a very simple step.
The remaining structure remains unchanged. map <sub-project name, map <reference value, result> indicates all the information of a sub-project.
(Of course, the map <reference value, result> in the inner layer can also be defined separately. But this is not important .)
========================================================== ====================================
This is the basic analysis.
Generate project information, which only consists of sub-projects.
Generate sub-project information, including only the project name and corresponding detection rules.
Analysis is one thing, but encoding is another thing.
========================================================== ====================================
1. The project name cannot be determined by the number of subitems.
2. A project composed of A, B, C, and D and A project composed of A, D, C, and B is actually A project.
Let's briefly talk about my methods, but I just want to keep my eyes open.
1. Write a set of code to indicate specific definitions,
2. Write a set of code to indicate specific use.
========================================================== ====================================
The definition is the result of the above analysis. Just write it out.
How about it? We need to analyze it a little.
========================================================== ====================================
How can we determine the projects that several sub-projects represent?
In terms of quantity, one component may be A, B, C, and D. The two components may be AB, AC, AD, BC, BD, and CD, the three components may be ABC, ABD, ACD, and BCD. The four components can only be ABCD.
In terms of name, the components A and B and A are called AB, which are composed of A, B, and C and composed of A, C, and B. (A number is omitted here) and C, B, And A are all called ABC.
========================================================== ====================================
This makes it clear that my approach is:
First, let's look at several sub-projects on hand,
Then let's see what the Sub-Project names will look like.
This is the simplest practice.
I used a tip, set stores data in sequence. This requires A relatively large <value. Put A and B in the set, and put B and A in the set. The result is the same.
(Of course, merging strings consumes a certain amount of time and space. You can also use other methods to look at your mood .)
========================================================== ====================================
In fact, the extra space used for these two sets of things is really insignificant in front of a large amount of data. The key is to support various projects that will be defined later.
In fact, you can use the database directly. Why do I have to do so many things in the memory?
Sometimes, you can do one thing only once. It is not that you want to access the database.
It seems that XML can also be used, but I don't like it.
========================================================== ====================================
Actually, I am a wheel maker.