You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
770 B
38 lines
770 B
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
class StringTest {
|
|
|
|
String mId;
|
|
|
|
int indexof_linear(String m) {
|
|
return m.indexOf('_');
|
|
}
|
|
|
|
int indexof_from_linear(String m, int j) {
|
|
return m.indexOf('_', j);
|
|
}
|
|
|
|
int indexof_quadratic(String m, String n) {
|
|
return m.indexOf(n);
|
|
}
|
|
|
|
int indexof_constant(String n) {
|
|
String m = "hi";
|
|
return m.indexOf('i');
|
|
}
|
|
|
|
public String index_substring_linear() {
|
|
int index = indexof_linear(mId);
|
|
return mId.substring(0, index);
|
|
}
|
|
|
|
private String startsWith_constant() {
|
|
String s = "";
|
|
return s.startsWith(",") ? s.substring(1) : s;
|
|
}
|
|
}
|