CodePointsOffsets (@NotNull CharSequence text) { IntList codePoints = new IntArrayList(text.length()); IntList offsets = new IntArrayList(text.length()); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (isPunctuation(c)) { codePoints.add(c); offsets.add(i); } } return new CodePointsOffsets(codePoints.toIntArray(), offsets.toIntArray()); }