stats returns a histogram of the number of each type of edit operation.
()
| 60 | |
| 61 | // stats returns a histogram of the number of each type of edit operation. |
| 62 | func (es EditScript) stats() (s struct{ NI, NX, NY, NM int }) { |
| 63 | for _, e := range es { |
| 64 | switch e { |
| 65 | case Identity: |
| 66 | s.NI++ |
| 67 | case UniqueX: |
| 68 | s.NX++ |
| 69 | case UniqueY: |
| 70 | s.NY++ |
| 71 | case Modified: |
| 72 | s.NM++ |
| 73 | default: |
| 74 | panic("invalid edit-type") |
| 75 | } |
| 76 | } |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | // Dist is the Levenshtein distance and is guaranteed to be 0 if and only if |
| 81 | // lists X and Y are equal. |