You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by iashok22 <gi...@git.apache.org> on 2017/10/05 07:07:58 UTC
[GitHub] commons-lang pull request #294: Added indexesOf method
GitHub user iashok22 opened a pull request:
https://github.com/apache/commons-lang/pull/294
Added indexesOf method
indexesOf () - Finds the indexes of all the occurrences of given search key found in the given string.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/iashok22/commons-lang master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/294.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #294
----
commit 18e4f8173eb6c1ea3cc11548b043e927544be084
Author: Ashok <ai...@paypal.com>
Date: 2017-08-31T06:36:55Z
Added string methods
commit f88768936fbd84f1393e64f6697641005cbef4b7
Author: Ashokkumar <ia...@gmail.com>
Date: 2017-09-26T09:56:11Z
Merge branch 'master' into master
commit 0de6f4e89060b7f1722c56a4f6e6d076cfb71a25
Author: Ashokkumar <ia...@gmail.com>
Date: 2017-09-26T10:19:50Z
Added missed line
commit c968df0af64838a4d9a48c4ae8d280ad299cbf81
Author: Ashokkumar <ia...@gmail.com>
Date: 2017-09-26T10:32:25Z
Update StringUtilsTest.java
commit 4d4a44697757e9e51ab751c98e1fff10e38d7cbe
Author: Ashokkumar <ia...@gmail.com>
Date: 2017-09-26T11:08:42Z
Changing input paramters mutable
commit 0ba11482813d94175e68c7fa1a0c07001c480721
Author: Ashok <ai...@paypal.com>
Date: 2017-10-05T06:14:27Z
Incorporating review comments
commit c7e2a794afef7925cae3741fcc1b8ec4c3f70ab5
Author: Ashok <ai...@paypal.com>
Date: 2017-10-05T06:18:28Z
merge conflicts
commit c5f9d43f80321a4833328221816c08fd90a64c6d
Author: Ashok <ai...@paypal.com>
Date: 2017-10-05T06:33:32Z
Fixing UT error
commit 347684d3655691a59bbbc1c8e9646eb5bd17c7f5
Author: Ashok <ai...@paypal.com>
Date: 2017-10-05T06:47:45Z
Code refactor
commit 0dff06c3f50da7c604efee628b8b4bda4e404c1f
Author: Ashok <ai...@paypal.com>
Date: 2017-10-05T06:50:14Z
fix
commit d63557fb5f57aaed14d765708023d80b711f35e7
Author: Ashok <ai...@paypal.com>
Date: 2017-10-05T07:04:45Z
Adding null check
----
---
[GitHub] commons-lang issue #294: Added indexesOf method
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the issue:
https://github.com/apache/commons-lang/pull/294
The question here is whether to use the more grammatically correct "indices" or the more casual "indexes".
---
[GitHub] commons-lang issue #294: Added indexesOf method
Posted by kedar-joshi <gi...@git.apache.org>.
Github user kedar-joshi commented on the issue:
https://github.com/apache/commons-lang/pull/294
Also, length of the `source` can be cached for better performance e.g.
```java
for (int i = 0, length = source.length(); i < length; i++)
{
if (searchKey.equals(source.charAt(i)))
{
indexList.add(i);
}
}
```
---
[GitHub] commons-lang issue #294: Added indexesOf method
Posted by kedar-joshi <gi...@git.apache.org>.
Github user kedar-joshi commented on the issue:
https://github.com/apache/commons-lang/pull/294
I think the method should return an empty collection instead of `null`
```java
if(isEmpty(source) || searchKey == null ) {
return Collections.emptyList();
}
```
---
[GitHub] commons-lang pull request #294: Added indexesOf method
Posted by Abrasha <gi...@git.apache.org>.
Github user Abrasha commented on a diff in the pull request:
https://github.com/apache/commons-lang/pull/294#discussion_r143189192
--- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
@@ -9245,25 +9245,28 @@ public static String unwrap(final String str, final char wrapChar) {
index += Character.charCount(result[i]);
}
return result;
- }
+ }
/**
* <p>Finds index of all the occurences of given search key found in source string.
* </p>
- * @param source
- * @param searchKey
+ * @param source
+ * input string to find indexes
+ * @param searchKey
+ * search character
* @return list of integer of indexes.
*/
public static List<Integer> indexesOf(final CharSequence source, final Character searchKey) {
if(isEmpty(source) || searchKey == null ) {
- return null;
- }
+ return null;
+ }
--- End diff --
Can you fix the formatting, please?
---
[GitHub] commons-lang pull request #294: Added indexesOf method
Posted by vsTianhao <gi...@git.apache.org>.
Github user vsTianhao commented on a diff in the pull request:
https://github.com/apache/commons-lang/pull/294#discussion_r156577062
--- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
@@ -9245,25 +9245,28 @@ public static String unwrap(final String str, final char wrapChar) {
index += Character.charCount(result[i]);
}
return result;
- }
+ }
/**
* <p>Finds index of all the occurences of given search key found in source string.
* </p>
- * @param source
- * @param searchKey
+ * @param source
+ * input string to find indexes
+ * @param searchKey
+ * search character
* @return list of integer of indexes.
*/
public static List<Integer> indexesOf(final CharSequence source, final Character searchKey) {
if(isEmpty(source) || searchKey == null ) {
- return null;
- }
+ return null;
+ }
--- End diff --
Ha-ha,They refused to merge only two lines of code modification
---