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 / Methods

ArrayClear

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.

ArrayCopy

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.

CompareBool


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.

CompareChar


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.

CompareFloat32


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.

CompareFloat64


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.

CompareInt16


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.

CompareInt32


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.

CompareInt64


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.

CompareInt8


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

The object or null.

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

EqualsBool


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.

EqualsChar


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.

EqualsFloat32


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.

EqualsFloat64


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.

EqualsInt16


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.

EqualsInt32


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.

EqualsInt64


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.

EqualsInt8


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.

GrowCapacity


[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.

IsValid


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.

MemoryConsumptionOf

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.

VarIntLength


[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.

VarIntRead

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.

VarIntWrite

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.