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:
parent
eac9add081
commit
5108fdc8fc
|
@ -1192,6 +1192,26 @@ public class StrBuilder implements Cloneable {
|
||||||
return this;
|
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.
|
* Checks whether this builder starts with the specified string.
|
||||||
|
@ -1540,25 +1560,6 @@ public class StrBuilder implements Cloneable {
|
||||||
return -1;
|
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.
|
* Gets the contents of this builder as a Reader.
|
||||||
|
|
Loading…
Reference in New Issue