BurntSushi / aho-corasick

A fast implementation of Aho-Corasick in Rust.
The Unlicense
1.03k stars 93 forks source link

Document order of returned matches #137

Open mcpower opened 11 months ago

mcpower commented 11 months ago

The order of the returned matches from AhoCorasick methods is not explicitly documented. While the order can be inferred from the examples given, it is not fully clear for overlapping matches.

The overlapping example shows that the .end() of matches is strictly non-decreasing, but it does not show the behaviour when two matches end at the same index. I assume there are a few possibilities for what happens in this case:

It would be helpful to document what happens in this case.

BurntSushi commented 11 months ago

Yeah I agree the docs could be improved here.

Even at the lowest layers of the public API, the order is specifically not mentioned. I'm wondering whether I did that intentionally.

(I believe the actual behavior is earliest PatternID first.)