canApply method
Fast check if this strategy can be applied to the given input and hint.
This method should be:
- Fast: avoid expensive computations or validations
- Pure: no side effects or state modifications
- Conservative: return false if uncertain
Example implementations:
// Binary search requires sorted input
bool canApply(List\<int\> input, SelectorHint hint) => hint.sorted == true;
// Insertion sort works well for small datasets
bool canApply(List\<int\> input, SelectorHint hint) => (hint.n ?? input.length) <= 50;
Implementation
@override
bool canApply(List<int> input, SelectorHint hint) {
final size = hint.n ?? input.length;
// Only beneficial for large datasets
if (size < _sequentialThreshold) return false;
// Check isolate support
try {
Isolate.current;
return true;
} catch (e) {
return false;
}
}