Find method must find an item in the list. Whether the list is sorted or not, whether the binary search optimization can be applied or not - are implementation details.
Find method should either: 1) Raise exception if list is not sorted, 2) Use IndexOf method if the list is not sorted (preferable). Adding optional parameters is hardly a good solution. Instead, add a FindSorted method. To summarise: procedure Find(const S: string; out Index: Integer):Boolean; begin if Sorted then Result := FindSorted(S, Index); else begin Index := IndexOf(S); Result := (Index >= 0); end; end; procedure FindSorted(const S: string; out Index: Integer):Boolean; begin if not Sorted then raise Exception.Create('List must be sorted'); // search logic here... end; Denis
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel