Move reverse method in file to be with other methods returning this

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@230912 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2005-08-08 22:05:19 +00:00
parent eac9add081
commit 5108fdc8fc
1 changed files with 20 additions and 19 deletions

View File

@ -1192,6 +1192,26 @@ public StrBuilder replace(String searchStr, String replaceStr) {
return this;
}
//-----------------------------------------------------------------------
/**
* Reverses the string builder placing each character in the opposite index.
*
* @return this, to enable chaining
*/
public StrBuilder reverse() {
if (size == 0) {
return this;
}
int half = size / 2;
for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++,rightIdx--) {
char swap = buffer[leftIdx];
buffer[leftIdx] = buffer[rightIdx];
buffer[rightIdx] = swap;
}
return this;
}
//-----------------------------------------------------------------------
/**
* Checks whether this builder starts with the specified string.
@ -1540,25 +1560,6 @@ public int lastIndexOf(String str, int startIndex) {
return -1;
}
/**
* Reverses the string builder placing each character in the opposite index.
*
* @return this, to enable chaining
*/
public StrBuilder reverse() {
if (size == 0) {
return this;
}
int half = size / 2;
for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++,rightIdx--) {
char swap = buffer[leftIdx];
buffer[leftIdx] = buffer[rightIdx];
buffer[rightIdx] = swap;
}
return this;
}
//-----------------------------------------------------------------------
/**
* Gets the contents of this builder as a Reader.