MCPcopy Create free account
hub / github.com/Aghajari/MathParser / findBestIndex

Method findBestIndex

MathParser/src/com/aghajari/math/Utils.java:104–118  ·  view source on GitHub ↗
(String src, boolean before)

Source from the content-addressed store, hash-verified

102 }
103
104 static int findBestIndex(String src, boolean before) {
105 int index = before ? src.lastIndexOf(' ') : src.indexOf(' ');
106 if (index == -1)
107 index = before ? 0 : src.length();
108 else if (before)
109 index++;
110
111 for (char c : MathParser.special) {
112 int id = before ? src.lastIndexOf(c) : src.indexOf(c);
113 if (id != -1)
114 index = before ? Math.max(index, id + 1) : Math.min(index, id);
115 }
116
117 return index;
118 }
119
120 /**
121 * Calculates the similarity (a number within 0 and 1) between two strings.

Callers 3

calculateMethod · 0.95
orderAgainMethod · 0.95
nextWordMethod · 0.95

Calls 2

maxMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected