SystemUtil

Description

static class Tinman.Core.System.SystemUtil

Provides static helper method for dealing with objects.

This class provides some helper methods, dealing with the following:

  • Clear ranges of arrays of primitive element-types to the default value, see ArrayClear.

  • Copy ranges between arrays of primitive element-types, see ArrayCopy.

  • Comparison methods for primitive types, compatible with CompareDelegate, see Compare*.

  • Equality methods for primitive types, compatible with EqualsDelegate.

  • Helpers for object disposal: IsValid, Dispose.

  • Helpers for estimating memory consumption, see MemoryConsumption*.

  • Pin object references, for safely passing them around as IntPtr values.

  • Sort fixed-length sequences of values, see Sort*.

  • Read and write 64-bit integer values using minimal byte count (between 1 and 9), see VarInt*.

Public / Constants

Delegate​Compare​Bool


[ShutdownSurvive]
public static readonly attribute DelegateCompareBool → (CompareDelegate<bool>)

The delegate for CompareBool.

Delegate​Compare​Char


[ShutdownSurvive]
public static readonly attribute DelegateCompareChar → (CompareDelegate<char>)

The delegate for CompareChar.

Delegate​Compare​Float32


[ShutdownSurvive]
public static readonly attribute DelegateCompareFloat32 → (CompareDelegate<float32>)

The delegate for CompareFloat32.

Delegate​Compare​Float64


[ShutdownSurvive]
public static readonly attribute DelegateCompareFloat64 → (CompareDelegate<float64>)

The delegate for CompareFloat64.

Delegate​Compare​Int16


[ShutdownSurvive]
public static readonly attribute DelegateCompareInt16 → (CompareDelegate<int16>)

The delegate for CompareInt16.

Delegate​Compare​Int32


[ShutdownSurvive]
public static readonly attribute DelegateCompareInt32 → (CompareDelegate<int32>)

The delegate for CompareInt32.

Delegate​Compare​Int64


[ShutdownSurvive]
public static readonly attribute DelegateCompareInt64 → (CompareDelegate<int64>)

The delegate for CompareInt64.

Delegate​Compare​Int8


[ShutdownSurvive]
public static readonly attribute DelegateCompareInt8 → (CompareDelegate<int8>)

The delegate for CompareInt8.

Delegate​Equals​Bool


[ShutdownSurvive]
public static readonly attribute DelegateEqualsBool → (EqualsDelegate<bool>)

The delegate for EqualsBool.

Delegate​Equals​Char


[ShutdownSurvive]
public static readonly attribute DelegateEqualsChar → (EqualsDelegate<char>)

The delegate for EqualsChar.

Delegate​Equals​Float32


[ShutdownSurvive]
public static readonly attribute DelegateEqualsFloat32 → (EqualsDelegate<float32>)

The delegate for EqualsFloat32.

Delegate​Equals​Float64


[ShutdownSurvive]
public static readonly attribute DelegateEqualsFloat64 → (EqualsDelegate<float64>)

The delegate for EqualsFloat64.

Delegate​Equals​Int16


[ShutdownSurvive]
public static readonly attribute DelegateEqualsInt16 → (EqualsDelegate<int16>)

The delegate for EqualsInt16.

Delegate​Equals​Int32


[ShutdownSurvive]
public static readonly attribute DelegateEqualsInt32 → (EqualsDelegate<int32>)

The delegate for EqualsInt32.

Delegate​Equals​Int64


[ShutdownSurvive]
public static readonly attribute DelegateEqualsInt64 → (EqualsDelegate<int64>)

The delegate for EqualsInt64.

Delegate​Equals​Int8


[ShutdownSurvive]
public static readonly attribute DelegateEqualsInt8 → (EqualsDelegate<int8>)

The delegate for EqualsInt8.

Delegate​Equals​Int​Ptr


[ShutdownSurvive]
public static readonly attribute DelegateEqualsIntPtr → (EqualsDelegate<IntPtr>)

The delegate for EqualsIntPtr.

Delegate​Hash​Code​Char


[ShutdownSurvive]
public static readonly attribute DelegateHashCodeChar → (HashCodeDelegate<char>)

The default hash code delegate for char.

Delegate​Hash​Code​Float32


[ShutdownSurvive]
public static readonly attribute DelegateHashCodeFloat32 → (HashCodeDelegate<float32>)

The default hash code delegate for float.

Delegate​Hash​Code​Float64


[ShutdownSurvive]
public static readonly attribute DelegateHashCodeFloat64 → (HashCodeDelegate<float64>)

The default hash code delegate for double.

Delegate​Hash​Code​Int32


[ShutdownSurvive]
public static readonly attribute DelegateHashCodeInt32 → (HashCodeDelegate<int32>)

The default hash code delegate for int.

Delegate​Hash​Code​Int64


[ShutdownSurvive]
public static readonly attribute DelegateHashCodeInt64 → (HashCodeDelegate<int64>)

The default hash code delegate for long.

Public / Methods

Array​Clear

8 overloads


public static method ArrayClear1 → (3)

array in : bool [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear2 → (3)

array in : int8 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear3 → (3)

array in : char [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear4 → (3)

array in : int16 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear5 → (3)

array in : int32 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear6 → (3)

array in : float32 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear7 → (3)

array in : int64 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method ArrayClear8 → (3)

array in : float64 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.

Array​Copy

8 overloads


public static method ArrayCopy1 → (5)

source in : bool [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : bool [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy2 → (5)

source in : int8 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int8 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy3 → (5)

source in : char [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : char [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy4 → (5)

source in : int16 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int16 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy5 → (5)

source in : int32 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int32 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy6 → (5)

source in : float32 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : float32 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy7 → (5)

source in : int64 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int64 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method ArrayCopy8 → (5)

source in : float64 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : float64 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.

Array​Equals

8 overloads


[Pure]
public static method ArrayEquals1 → (2)

in : bool [ ]

The first array to compare.

in : bool [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals2 → (2)

in : int8 [ ]

The first array to compare.

in : int8 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals3 → (2)

in : char [ ]

The first array to compare.

in : char [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals4 → (2)

in : int16 [ ]

The first array to compare.

in : int16 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals5 → (2)

in : int32 [ ]

The first array to compare.

in : int32 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals6 → (2)

in : float32 [ ]

The first array to compare.

in : float32 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals7 → (2)

in : int64 [ ]

The first array to compare.

in : int64 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method ArrayEquals8 → (2)

in : float64 [ ]

The first array to compare.

in : float64 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.

Compare​Bool


[Pure]
public static method CompareBool → (2)

in : bool

The first value.

in : bool

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

false is less then true.

Compare​Char


[Pure]
public static method CompareChar → (2)

in : char

The first value.

in : char

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Compare​Float32


[Pure]
public static method CompareFloat32 → (2)

in : float32

The first value.

in : float32

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Compare​Float64


[Pure]
public static method CompareFloat64 → (2)

in : float64

The first value.

in : float64

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Compare​Int16


[Pure]
public static method CompareInt16 → (2)

in : int16

The first value.

in : int16

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Compare​Int32


[Pure]
public static method CompareInt32 → (2)

in : int32

The first value.

in : int32

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Compare​Int64


[Pure]
public static method CompareInt64 → (2)

in : int64

The first value.

in : int64

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Compare​Int8


[Pure]
public static method CompareInt8 → (2)

in : int8

The first value.

in : int8

The second value.

returns → int32

+1 : if in is greater than in,
0 : if in is equal to in,
-1 : if in is less than in.

Compares the given values.

Dispose


public static method Dispose → (1)

obj in : object own

The object or null.

Disposes the given object if it is an instance of IDisposable.

Equals​Bool


public static method EqualsBool → (2)

in : bool

The first value.

in : bool

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Char


[Pure]
public static method EqualsChar → (2)

in : char

The first value.

in : char

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Float32


[Pure]
public static method EqualsFloat32 → (2)

in : float32

The first value.

in : float32

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Float64


[Pure]
public static method EqualsFloat64 → (2)

in : float64

The first value.

in : float64

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Int16


[Pure]
public static method EqualsInt16 → (2)

in : int16

The first value.

in : int16

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Int32


[Pure]
public static method EqualsInt32 → (2)

in : int32

The first value.

in : int32

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Int64


[Pure]
public static method EqualsInt64 → (2)

in : int64

The first value.

in : int64

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Int8


[Pure]
public static method EqualsInt8 → (2)

in : int8

The first value.

in : int8

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Equals​Int​Ptr


[Pure]
public static method EqualsIntPtr → (2)

in : IntPtr

The first value.

in : IntPtr

The second value.

returns → bool

true if in and in are equal,
false if they are different.

Compares the given values for equality.

Grow​Capacity


[Pure]
public static method GrowCapacity → (4)

current in : int32

The current capacity.

required opt : int64 = 0

The required capacity.

numerator opt : int32 = 5

Numerator of fraction to use for growing current in.

denominator opt : int32 = 4

Denominator of fraction to use for growing current in.

returns → int32

The grown capacity.

Grows the given capacity, making sure it stays within [0..2147483647] and is larger than or equal to required opt.

Is​Valid


public static method IsValid → (1)

obj in : object

The object to check.

returns → bool

true if the object is valid, false if not.

Is this object valid (see remarks)?

An object is considered valid if it is in one of the following lifecycle states:

An non-null object that does not implement the ILifecycleState interface is always valid. Null objects are always invalid.

Memory​Consumption​Of

10 overloads


[Pure]
public static method MemoryConsumptionOf1 → (1)

thing in : IMemoryConsumption

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf2 → (1)

thing in : ByteBuffer

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf3 → (1)

thing in : object

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf4 → (1)

thing in : bool [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf5 → (1)

thing in : int8 [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf6 → (1)

thing in : int16 [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf7 → (1)

thing in : int32 [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf8 → (1)

thing in : int64 [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf9 → (1)

thing in : float32 [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.


[Pure]
public static method MemoryConsumptionOf10 → (1)

thing in : float64 [ ]

The thing.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given thing.

Pin

2 overloads


public static method Pin1 → (1)

obj in : object

The object to pin or null.

returns → IntPtr

The opaque pin value for the given object. If IntPtr.Zero, the Pin2 method does not need to be called. Will be IntPtr.Zero iff obj in is null.

Returns pin for the given object.

For each call to Pin1, the Pin2 method must be called at least once, where the last call must free the pin.


public static method Pin2 → (2)

pin in : IntPtr

The opaque pin value or IntPtr.Zero.

release in : bool

Free the pin after returning the object?

returns → object

The object or null iff pin in is IntPtr.Zero.

Returns the object of the given pin.

Sort4

2 overloads


[Pure]
public static method Sort41 → (4)

d0 in : int64

First value to sort.

d1 in : int64

Second value to sort.

d2 in : int64

Third value to sort.

d3 in : int64

Fourth value to sort.

returns → int32

Bits 0..1 : sort order index of d0 in
Bits 2..3 : sort order index of d1 in
Bits 4..5 : sort order index of d2 in
Bits 6..7 : sort order index of d3 in

Sorts the given values.


[Pure]
public static method Sort42 → (4)

d0 in : float64

First value to sort.

d1 in : float64

Second value to sort.

d2 in : float64

Third value to sort.

d3 in : float64

Fourth value to sort.

returns → int32

Bits 0..1 : sort order index of d0 in
Bits 2..3 : sort order index of d1 in
Bits 4..5 : sort order index of d2 in
Bits 6..7 : sort order index of d3 in

Sorts the given values.

Sort8

2 overloads


[Pure]
public static method Sort81 → (8)

d0 in : int64

First value to sort.

d1 in : int64

Second value to sort.

d2 in : int64

Third value to sort.

d3 in : int64

Fourth value to sort.

d4 in : int64

Fifth value to sort.

d5 in : int64

Sixth value to sort.

d6 in : int64

Seventh value to sort.

d7 in : int64

Eighth value to sort.

returns → int32

Bits 0.. 2 : sort order index of d0 in
Bits 3.. 5 : sort order index of d1 in
Bits 6.. 8 : sort order index of d2 in
Bits 9..11 : sort order index of d3 in
Bits 12..14 : sort order index of d4 in
Bits 15..17 : sort order index of d5 in
Bits 18..20 : sort order index of d6 in
Bits 21..23 : sort order index of d7 in

Sorts the given values.


[Pure]
public static method Sort82 → (8)

d0 in : float64

First value to sort.

d1 in : float64

Second value to sort.

d2 in : float64

Third value to sort.

d3 in : float64

Fourth value to sort.

d4 in : float64

Fifth value to sort.

d5 in : float64

Sixth value to sort.

d6 in : float64

Seventh value to sort.

d7 in : float64

Eighth value to sort.

returns → int32

Bits 0.. 2 : sort order index of d0 in
Bits 3.. 5 : sort order index of d1 in
Bits 6.. 8 : sort order index of d2 in
Bits 9..11 : sort order index of d3 in
Bits 12..14 : sort order index of d4 in
Bits 15..17 : sort order index of d5 in
Bits 18..20 : sort order index of d6 in
Bits 21..23 : sort order index of d7 in

Sorts the given values.

Var​Int​Length


[Pure]
public static method VarIntLength → (1)

value in : int64

The value to encode.

returns → int32

The number of required bytes.

Returns the number of bytes that are required to encode the given value using variable coding from one to nine bytes.

Var​Int​Read

2 overloads


public static method VarIntRead1 → (1)

stream in : IBinaryReader

[not-null]
The input data stream.

returns → int64

The read value.

Reads a signed 64-bit value from the IDataStream using variable coding from one to nine bytes.

The encoding is independent on byte endianness.

IOException

If an I/O error has occurred.


public static method VarIntRead2 → (1)

buffer in : ByteBuffer

[not-null]
The input byte buffer.

returns → int64

The read value.

Reads a signed 64-bit value from the ByteBuffer using variable coding from one to nine bytes.

The encoding is independent on byte endianness.

Var​Int​Write

2 overloads


public static method VarIntWrite1 → (2)

stream in : IBinaryWriter

[not-null]
The output stream.

value in : int64

The value to write.

Writes a signed 64-bit value to the IDataStream using variable coding from one to nine bytes.

The encoding is independent on byte endianness.

IOException

If an I/O error has occurred.


public static method VarIntWrite2 → (2)

buffer in : ByteBuffer

[not-null]
The output byte buffer.

value in : int64

The value to write.

Writes a signed 64-bit value to the ByteBuffer using variable coding from one to nine bytes.

The encoding is independent on byte endianness.