-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from koculu/69-enhancement-add-serializers-and…
…-comparers-for-unsigned-primitive-types Enhancement: add serializers and comparers for unsigned primitive types
- Loading branch information
Showing
28 changed files
with
137 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class DecimalComparerDescending : IRefComparer<decimal> | ||
{ | ||
public int Compare(in decimal x, in decimal y) | ||
{ | ||
return y.CompareTo(x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class DoubleComparerDescending: IRefComparer<double> | ||
public sealed class DoubleComparerDescending : IRefComparer<double> | ||
{ | ||
public int Compare(in double x, in double y) | ||
{ | ||
var r = y - x; | ||
if (r == 0) | ||
return 0; | ||
return r < 0 ? -1 : 1; | ||
return y.CompareTo(x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class UInt16ComparerAscending : IRefComparer<ushort> | ||
{ | ||
public int Compare(in ushort x, in ushort y) | ||
{ | ||
return x.CompareTo(y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class UInt16ComparerDescending : IRefComparer<ushort> | ||
{ | ||
public int Compare(in ushort x, in ushort y) | ||
{ | ||
return y.CompareTo(x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class UInt32ComparerAscending : IRefComparer<uint> | ||
{ | ||
public int Compare(in uint x, in uint y) | ||
{ | ||
return x.CompareTo(y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class UInt32ComparerDescending : IRefComparer<uint> | ||
{ | ||
public int Compare(in uint x, in uint y) | ||
{ | ||
return y.CompareTo(x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class UInt64ComparerAscending : IRefComparer<ulong> | ||
{ | ||
public int Compare(in ulong x, in ulong y) | ||
{ | ||
return x.CompareTo(y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Tenray.ZoneTree.Comparers; | ||
|
||
public sealed class UInt64ComparerDescending : IRefComparer<ulong> | ||
{ | ||
public int Compare(in ulong x, in ulong y) | ||
{ | ||
return y.CompareTo(x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ public Memory<byte> Serialize(in short entry) | |
{ | ||
return BitConverter.GetBytes(entry); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Tenray.ZoneTree.Serializers; | ||
|
||
public sealed class UInt16Serializer : ISerializer<ushort> | ||
{ | ||
public ushort Deserialize(Memory<byte> bytes) | ||
{ | ||
return BitConverter.ToUInt16(bytes.Span); | ||
} | ||
|
||
public Memory<byte> Serialize(in ushort entry) | ||
{ | ||
return BitConverter.GetBytes(entry); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Tenray.ZoneTree.Serializers; | ||
|
||
public sealed class UInt32Serializer : ISerializer<uint> | ||
{ | ||
public uint Deserialize(Memory<byte> bytes) | ||
{ | ||
return BitConverter.ToUInt32(bytes.Span); | ||
} | ||
|
||
public Memory<byte> Serialize(in uint entry) | ||
{ | ||
return BitConverter.GetBytes(entry); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Tenray.ZoneTree.Serializers; | ||
|
||
public sealed class UInt64Serializer : ISerializer<ulong> | ||
{ | ||
public ulong Deserialize(Memory<byte> bytes) | ||
{ | ||
return BitConverter.ToUInt64(bytes.Span); | ||
} | ||
|
||
public Memory<byte> Serialize(in ulong entry) | ||
{ | ||
return BitConverter.GetBytes(entry); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters