Skip to content

Commit 595d7f4

Browse files
committed
ad
1 parent ab48c6a commit 595d7f4

5 files changed

Lines changed: 51 additions & 16 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
using CommunityToolkit.Diagnostics;
3+
4+
namespace NiTiS;
5+
6+
// public partial class MutableString : IComparable<MutableString>, IComparable<string>, IComparable
7+
// {
8+
// }

src/MutableString/MutableString.Enumerator.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@
33

44
namespace NiTiS;
55

6-
public partial class MutableString
6+
public partial class MutableString : IEnumerable<char>
77
{
8+
/// <inheritdoc/>
9+
public IEnumerator<char> GetEnumerator()
10+
{
11+
return new Enumerator(this);
12+
}
13+
14+
/// <inheritdoc/>
15+
IEnumerator IEnumerable.GetEnumerator()
16+
{
17+
return this.GetEnumerator();
18+
}
19+
820
private sealed class Enumerator : IEnumerator<char>
921
{
1022
private MutableString instance;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Buffers;
2+
3+
namespace NiTiS;
4+
5+
public partial class MutableString
6+
{
7+
#if false
8+
internal static class SearchValuesStorage
9+
{
10+
/// <summary>
11+
/// SearchValues would use SpanHelpers.IndexOfAnyValueType for 5 values in this case.
12+
/// No need to allocate the SearchValues as a regular Span.IndexOfAny will use the same implementation.
13+
/// </summary>
14+
public const string NewLineCharsExceptLineFeed = "\r\f\u0085\u2028\u2029";
15+
16+
/// <summary>
17+
/// The Unicode Standard, Sec. 5.8, Recommendation R4 and Table 5-2 state that the CR, LF,
18+
/// CRLF, NEL, LS, FF, and PS sequences are considered newline functions. That section
19+
/// also specifically excludes VT from the list of newline functions, so we do not include
20+
/// it in the needle list.
21+
/// </summary>
22+
public static readonly SearchValues<char> NewLineChars =
23+
SearchValues.Create(NewLineCharsExceptLineFeed + "\n");
24+
}
25+
#endif
26+
}

src/MutableString/MutableString.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace NiTiS;
1616
/// </summary>
1717
[DebuggerDisplay("{ToString()}")]
1818
[DebuggerTypeProxy(typeof(MutableStringDebugView))]
19-
public sealed partial class MutableString : IEnumerable<char>, IEquatable<MutableString?>, IEquatable<string?>
19+
public sealed partial class MutableString : IEquatable<MutableString?>, IEquatable<string?>
2020
{
2121
private const int DefaultCapacity = 32;
2222

@@ -836,18 +836,6 @@ public bool Equals(ReadOnlySpan<char> other)
836836
return true;
837837
}
838838

839-
/// <inheritdoc/>
840-
public IEnumerator<char> GetEnumerator()
841-
{
842-
return new Enumerator(this);
843-
}
844-
845-
/// <inheritdoc/>
846-
IEnumerator IEnumerable.GetEnumerator()
847-
{
848-
return this.GetEnumerator();
849-
}
850-
851839
/// <summary>
852840
/// Copy content of <see cref="MutableString"/> to new immutable <see cref="string"/>.
853841
/// </summary>

src/MutableString/MutableStringDebugView.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ namespace NiTiS;
33
internal sealed class MutableStringDebugView
44
{
55
private readonly MutableString data;
6+
67
public MutableStringDebugView(MutableString data)
78
{
89
this.data = data;
910
}
1011

11-
public int Length { get { return data.Length; } }
12-
public int Capacity { get { return data.Capacity; } }
12+
public int Length => data.Length;
13+
public int Capacity => data.Capacity;
1314
}

0 commit comments

Comments
 (0)