Class CharOrTerminatorComparer
An implementation of
Inheritance
System.Object
CharOrTerminatorComparer
Namespace: MoreStructures.Utilities
Assembly: MoreStructures.dll
Syntax
public class CharOrTerminatorComparer : IComparer<char>
Properties
| Improve this Doc View SourceTerminator
The character acting as terminator, and which has to be considered smaller than any other char.
Declaration
public char Terminator { get; }
Property Value
Type | Description |
---|---|
System.Char |
Methods
| Improve this Doc View SourceBuild(Char)
Builds a CharOrTerminatorComparer with the provided terminator
. Caches
instances.
Declaration
public static CharOrTerminatorComparer Build(char terminator)
Parameters
Type | Name | Description |
---|---|---|
System.Char | terminator |
Returns
Type | Description |
---|---|
CharOrTerminatorComparer | An instance of CharOrTerminatorComparer, new or previously created and cached. |
Compare(Char, Char)
Declaration
public int Compare(char x, char y)
Parameters
Type | Name | Description |
---|---|---|
System.Char | x | |
System.Char | y |
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
Special rules applied by CharOrTerminatorComparer:
- If one char is the terminator, and the other isn't, the one which is the terminator is smaller.
- If none of the cases above applies, System.Char.CompareTo(System.Char) is used on
x
andy
.
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Two CharOrTerminatorComparer are equal if they have the same Terminator.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
The GetHashCode() is based on Terminator hash.