MCPcopy Create free account
hub / github.com/antlr/codebuff / removeFrom

Method removeFrom

output/java_guava/1.4.16/CharMatcher.java:779–805  ·  view source on GitHub ↗

Returns a string containing all non-matching characters of a character sequence, in order. For example: CharMatcher.is('a').removeFrom("bazaar") ... returns "bzr".

(CharSequence sequence)

Source from the content-addressed store, hash-verified

777
778
779 public String removeFrom(CharSequence sequence) {
780 String string = sequence.toString();
781 int pos = indexIn(string);
782 if (pos == -1) {
783 return string;
784 }
785 char[] chars = string.toCharArray();
786 int spread = 1;
787
788 // This unusual loop comes from extensive benchmarking
789 OUT:
790 while (true) {
791 pos++;
792 while (true) {
793 if (pos == chars.length) {
794 break OUT;
795 }
796 if (matches(chars[pos])) {
797 break;
798 }
799 chars[pos - spread] = chars[pos];
800 pos++;
801 }
802 spread++;
803 }
804 return new String(chars, 0, pos - spread);
805 }
806
807 /**
808 * Returns a string containing all matching characters of a character sequence, in order. For

Callers 4

replaceFromMethod · 0.95
canDecodeMethod · 0.45
decodeToMethod · 0.45
retainFromMethod · 0.45

Calls 4

indexInMethod · 0.95
matchesMethod · 0.95
toStringMethod · 0.65
toCharArrayMethod · 0.45

Tested by

no test coverage detected