The scene is introduced
- In the matching service, one set of accessories (interference source) and another set of accessories (target source) are mutually exclusive or mutually dependent.
- details
- There is no order in which accessories are selected
- A class of accessories can be single or multiple options
- Trigger: In unidirectional mode, the interference source conditions on the left are met. In bidirectional mode, the interference source conditions are met
- Meet: that is, both the left and right conditions are met
- Expression example
- eg: (A || B) && ! C1 => E || (F && G)
- (A or B) and not C1 unidirectional dependent on E or (F and G)
- If C1 belongs to a class that includes C1, C2, and C3, then! C1, C2 or C3 choose one of them
demand
- When the expression is triggered, the necessary validation is provided when the expression is selected by the user
- Dependency: When the expression is triggered, but not satisfied, the required prompt
- Mutual exclusion: During the selection process, when the expression meets the mutual exclusion prompt
- Problem tip: Show the expression, green – selected item, orange – mutually exclusive item, gray – unselected item, red – current selection
The original data
- Expression data
{relType, // relType, // relType, // relType, // relType, // relType, // relType, // relType, // relType, // relType, // relType, //Copy the code
- The source data
[{join, / / and non - 2, or - 1, / / non - 1, and 0 parenthesis, / / (1), 2}]Copy the code
Implementation approach
- Data structure
- And/or
- And: denotes Set, Set
- Or: in terms of arrays, Array
- (A || B) && C
- For easy display, the inner layer represents Set and the outer layer represents Array
[[A, C],[B, C]]
- Non case processing
- The remaining items of the same kind or
- (B || ! C1) && D
- ! C1 =>
[C2, C3]
[[B, D],[C2, D], [C3, D]]
- parentheses
- As with the example above, finally expand
- Two-way/single
- Process maps with dictionaries
- Bidirectional dependencies spread out into two unidirectional pushes into the dictionary
- Bidirectional mutex can be treated as unidirectional mutex
- And/or
- Structured data algorithm
- Cut or not
- After data processing, flattening is carried out
- parentheses
- Refer to the calculator algorithm
- Cut or not
- Idea of matching algorithm
- Using the Set Set
- The selected options and the options in each and set of source expanded data form a new set, the length of the new set is equal to the number of selected types, which is triggered
[match1, match2, ...]
new Set([...selects, ...match[n]])
- show
- It can be implemented as a normal front-end UI