CharSegment has bug in Equals method
|
public override bool Equals(Segment<char> other) |
|
{ |
|
bool contentEqualityComparer(IList<char> left, IList<char> right) |
|
{ |
|
// Base can be not an array, but still IList<char> |
|
if (Base is char[] baseArray && other.Base is char[] otherArray) |
|
{ |
|
return baseArray.ContentEqualTo(Offset, Length, otherArray, other.Offset); |
|
} |
|
else |
|
{ |
|
return left.ContentEqualTo(right); |
|
} |
|
} |
|
return this.EqualTo(other, contentEqualityComparer); |
|
} |
Fix it
Small example [use this sandbox and add property PublicDictionary to Walker4]:
/*
public IDictionary<CharSegment, long> PublicDictionary
{
get => Dictionary;
}
*/
var text = "aaaaaaaaaa";
var walker = new Walker4();
walker.WalkAll(text);
foreach (var l in walker.PublicDictionary)
{
foreach (var r in walker.PublicDictionary)
{
Console.WriteLine($"{l} == {r} ==> {l.Key.Equals(r.Key)}");
}
}
CharSegment has bug in Equals method
Collections/csharp/Platform.Collections/Segments/CharSegment.cs
Lines 31 to 46 in 3643cf1
Fix it
Small example [use this sandbox and add property
PublicDictionarytoWalker4]: