This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new faa0b94 Made IAppendable methods an explicit IAppendable declaration
and ensured consistency using count instead of length in Append overloads (#240)
faa0b94 is described below
commit faa0b944de339a0a7cd8dc83be4534de8c20d758
Author: bongohrtech <[email protected]>
AuthorDate: Wed Apr 15 18:21:39 2020 +0700
Made IAppendable methods an explicit IAppendable declaration and ensured
consistency using count instead of length in Append overloads (#240)
Co-authored-by: Michael Condillac <[email protected]>
---
.../Analysis/Util/OpenStringBuilder.cs | 83 ++++++++++++++++++----
1 file changed, 71 insertions(+), 12 deletions(-)
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
index 0f41a0f..9e2a099 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
@@ -26,12 +26,12 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// A StringBuilder that allows one to access the array.
/// </summary>
- public class OpenStringBuilder : ICharSequence
+ public class OpenStringBuilder : IAppendable, ICharSequence
{
protected char[] m_buf;
protected int m_len;
- public OpenStringBuilder()
+ public OpenStringBuilder()
: this(32)
{
}
@@ -73,15 +73,15 @@ namespace Lucene.Net.Analysis.Util
public virtual int Capacity => m_buf.Length;
- public virtual OpenStringBuilder Append(ICharSequence csq)
+ public virtual OpenStringBuilder Append(ICharSequence csq)
{
return Append(csq, 0, csq.Length);
}
- public virtual OpenStringBuilder Append(ICharSequence csq, int
startIndex, int length) // LUCENENET TODO: API - change to startIndex/length to
match .NET
+ public virtual OpenStringBuilder Append(ICharSequence csq, int
startIndex, int count) // LUCENENET TODO: API - change to startIndex/length to
match .NET
{
- EnsureCapacity(length - startIndex);
- for (int i = startIndex; i < length; i++)
+ EnsureCapacity(count - startIndex);
+ for (int i = startIndex; i < count; i++)
{
UnsafeWrite(csq[i]);
}
@@ -95,10 +95,10 @@ namespace Lucene.Net.Analysis.Util
}
// LUCENENET specific - overload for string (more common in .NET than
ICharSequence)
- public virtual OpenStringBuilder Append(string csq, int startIndex,
int length) // LUCENENET TODO: API - change to startIndex/length to match .NET
+ public virtual OpenStringBuilder Append(string csq, int startIndex,
int count) // LUCENENET TODO: API - change to startIndex/length to match .NET
{
- EnsureCapacity(length - startIndex);
- for (int i = startIndex; i < length; i++)
+ EnsureCapacity(count - startIndex);
+ for (int i = startIndex; i < count; i++)
{
UnsafeWrite(csq[i]);
}
@@ -112,10 +112,10 @@ namespace Lucene.Net.Analysis.Util
}
// LUCENENET specific - overload for StringBuilder
- public virtual OpenStringBuilder Append(StringBuilder csq, int
startIndex, int length) // LUCENENET TODO: API - change to startIndex/length to
match .NET
+ public virtual OpenStringBuilder Append(StringBuilder csq, int
startIndex, int count) // LUCENENET TODO: API - change to startIndex/length to
match .NET
{
- EnsureCapacity(length - startIndex);
- for (int i = startIndex; i < length; i++)
+ EnsureCapacity(count - startIndex);
+ for (int i = startIndex; i < count; i++)
{
UnsafeWrite(csq[i]);
}
@@ -128,6 +128,20 @@ namespace Lucene.Net.Analysis.Util
return this;
}
+ public virtual OpenStringBuilder Append(char[] value)
+ {
+ Write(value);
+ return this;
+ }
+ public virtual OpenStringBuilder Append(char[] value, int startIndex,
int count)
+ {
+ EnsureCapacity(count - startIndex);
+ for (int i = startIndex; i < count; i++)
+ {
+ UnsafeWrite(value[i]);
+ }
+ return this;
+ }
// LUCENENET specific - removed (replaced with this[])
//public virtual char CharAt(int index)
//{
@@ -270,5 +284,50 @@ namespace Lucene.Net.Analysis.Util
{
return new string(m_buf, 0, Length);
}
+
+ IAppendable IAppendable.Append(char value)
+ {
+ return Append(value);
+ }
+
+ IAppendable IAppendable.Append(string value)
+ {
+ return Append(value);
+ }
+
+ IAppendable IAppendable.Append(string value, int startIndex, int count)
+ {
+ return Append(value, startIndex, count);
+ }
+
+ IAppendable IAppendable.Append(StringBuilder value)
+ {
+ return Append(value);
+ }
+
+ IAppendable IAppendable.Append(StringBuilder value, int startIndex,
int count)
+ {
+ return Append(value, startIndex, count);
+ }
+
+ IAppendable IAppendable.Append(char[] value)
+ {
+ return Append(value);
+ }
+
+ IAppendable IAppendable.Append(char[] value, int startIndex, int count)
+ {
+ return Append(value, startIndex, count);
+ }
+
+ IAppendable IAppendable.Append(ICharSequence value)
+ {
+ return Append(value);
+ }
+
+ IAppendable IAppendable.Append(ICharSequence value, int startIndex,
int count)
+ {
+ return Append(value, startIndex, count);
+ }
}
}
\ No newline at end of file