chapel
chapel copied to clipboard
Add keyComparator, keyPartComparator, and relativeComparator
This is an implementation issue for part of the new Sort module API from https://github.com/chapel-lang/chapel/issues/24857
This is a followup to https://github.com/chapel-lang/chapel/issues/25552, which should be implemented first
Instead of relying on special methods/records, the sort API will use interfaces. These interfaces work as follows
- A record that implements
keyComparator
requires implementing thekey
method - A record that implements
keyPartComparator
requires implementing thekeyPart
method. Implementing thecompare
method is optional - A record that implements
relativeComparator
requires implementing thecompare
method
Any record that implements more than one of these interfaces should cause a compiler error
The Sort module implementation should use these interfaces when sorting to check if a comparator is valid, replacing the need for chpl_check_comparator