Show / Hide Table of Contents

Class BinaryTransformations

Provides various binary transformations.

Inheritance
object
BinaryTransformations
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Buffers.Binary
Assembly: DotNext.dll
Syntax
public static class BinaryTransformations

Methods

View Source

AndNot<T>(ReadOnlySpan<T>, Span<T>)

Performs bitwise AND-NOT operation between two vectors in-place.

Declaration
public static void AndNot<T>(this ReadOnlySpan<T> x, Span<T> y) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> x

The first vector.

Span<T> y

The second vector. It will be replaced with a result of operation.

Type Parameters
Name Description
T

The type of elements in vector.

Exceptions
Type Condition
ArgumentOutOfRangeException

The length of x is not equal to y.

View Source

BitwiseAnd<T>(ReadOnlySpan<T>, Span<T>)

Performs bitwise AND operation between two vectors in-place.

Declaration
public static void BitwiseAnd<T>(this ReadOnlySpan<T> x, Span<T> y) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> x

The first vector.

Span<T> y

The second vector. It will be replaced with a result of operation.

Type Parameters
Name Description
T

The type of elements in vector.

Exceptions
Type Condition
ArgumentOutOfRangeException

The length of x is not equal to y.

View Source

BitwiseOr<T>(ReadOnlySpan<T>, Span<T>)

Performs bitwise OR operation between two vectors in-place.

Declaration
public static void BitwiseOr<T>(this ReadOnlySpan<T> x, Span<T> y) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> x

The first vector.

Span<T> y

The second vector. It will be replaced with a result of operation.

Type Parameters
Name Description
T

The type of elements in vector.

Exceptions
Type Condition
ArgumentOutOfRangeException

The length of x is not equal to y.

View Source

BitwiseXor<T>(ReadOnlySpan<T>, Span<T>)

Performs bitwise XOR operation between two vectors in-place.

Declaration
public static void BitwiseXor<T>(this ReadOnlySpan<T> x, Span<T> y) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> x

The first vector.

Span<T> y

The second vector. It will be replaced with a result of operation.

Type Parameters
Name Description
T

The type of elements in vector.

Exceptions
Type Condition
ArgumentOutOfRangeException

The length of x is not equal to y.

View Source

Format<T>(T, MemoryAllocator<byte>?)

Formats object as a sequence of bytes.

Declaration
public static MemoryOwner<byte> Format<T>(this T value, MemoryAllocator<byte>? allocator = null) where T : IBinaryFormattable<T>
Parameters
Type Name Description
T value
MemoryAllocator<byte> allocator

The memory allocator.

Returns
Type Description
MemoryOwner<byte>

The buffer containing formatted value.

Type Parameters
Name Description
T
View Source

OnesComplement<T>(Span<T>)

Inverts all bits within the provided vector in-place.

Declaration
public static void OnesComplement<T>(this Span<T> values) where T : unmanaged
Parameters
Type Name Description
Span<T> values

The vector to modify.

Type Parameters
Name Description
T

The type of elements in vector.

View Source

Parse<T>(in ReadOnlySequence<byte>)

Restores the object from its binary representation.

Declaration
public static T Parse<T>(in ReadOnlySequence<byte> source) where T : IBinaryFormattable<T>
Parameters
Type Name Description
ReadOnlySequence<byte> source

The input buffer.

Returns
Type Description
T

The restored object.

Type Parameters
Name Description
T
View Source

Reverse<T>(ref T)

Reverse bytes in the specified value of blittable type.

Declaration
public static void Reverse<T>(ref T value) where T : unmanaged
Parameters
Type Name Description
T value

The value which bytes should be reversed.

Type Parameters
Name Description
T

Blittable type.

View Source

TryFormat<T>(T, Span<byte>)

Attempts to format object as a sequence of bytes.

Declaration
public static bool TryFormat<T>(this T value, Span<byte> destination) where T : IBinaryFormattable<T>
Parameters
Type Name Description
T value
Span<byte> destination

The output buffer.

Returns
Type Description
bool

true if the value converted successfully; otherwise, false.

Type Parameters
Name Description
T
View Source

TryParse<T>(scoped ReadOnlySpan<byte>, out T?)

Attempts to restore the object from its binary representation.

Declaration
public static bool TryParse<T>(scoped ReadOnlySpan<byte> source, out T? result) where T : IBinaryFormattable<T>
Parameters
Type Name Description
ReadOnlySpan<byte> source

The input buffer.

T result

The restored object.

Returns
Type Description
bool

true if the parsing done successfully; otherwise, false.

Type Parameters
Name Description
T
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾