what I should send for matchTable:
selector?
in the implementation, there are no examples or detailed explanation so
I don't understand which object is getting the message if I put the string in in:
selector
The matchTable:
keyword provides a way to identify characters so that they become equivalent in comparisons. The argument is usually a ByteArray
of 256
entries, containing at position i
the code point of the i
th character to be considered when comparing.
The main use of the table is to implement case-insensitive searches, where, e.g., A=a
. Thus, instead of comparing the characters at hand during the search, what are compared are the elements found in the matchTable
at their respective code points. So, instead of
(string1 at: i) = (string2 at: j)
the testing becomes something on the lines of
cp1 := string1 basicAt: i.
cp2 := string2 basicAt: j.
(table at: cp1) = (table at: cp2).
In other words, the matchTable:
argument is used to map actual characters to the ones that actually matter for the comparisons.
Note that the same technique can be applied for case-sensitive/insensitive sorting.
Finally, bear in mind that this is a rather low-level method that non-system programmers would rarely need. You should be using instead higher level versions for finding substrings such as findString:startingAt:caseSensitive:
, where the argument of the last keyword is a Boolean
.