3 ms·
It only has to be an abstract class if you want to prevent the existence of invalid offsets, but the same is true if you have constant width code points. For in
by TheCoelacanth 11y ago
It only has to be an abstract class if you want to prevent the existence of invalid offsets, but the same is true if you have constant width code points. For instance, INT_MAX is not a valid offset into almost any string.
- lisper 11y ago> It only has to be an abstract class if you want to prevent the existence of invalid offsets Wouldn't you want that? I would. > the same is true if you have constant width code points True, but the validity check for the constant-width case can be done in constant time.
- TheCoelacanth 11y ago> True, but the validity check for the constant-width case can be done in constant time. The same is true of UTF-8 because it is self-synchronizing. You only have to check that the byte at the given offset is either 0xxxxxxx or 11xxxxxx.
- lisper 11y agoHm, that's a good point.