SystemUtil

Description

static class Tinman.Core.SystemUtil

Provides static helper method for dealing with objects.

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

  • Comparison methods, compatible with EqualsDelegate, see Compare*.

  • Type conversion methods, see Convert*.

  • Equality methods, compatible with HashCodeDelegate.

  • Hash code methods, compatible with CompareDelegate, see HashCode*.

  • Helpers for estimating memory consumption, see MemoryConsumptionOf*.

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

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

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.

See also

CompareDelegate

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.

See also

CompareDelegate

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.

See also

CompareDelegate

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.

See also

CompareDelegate

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.

See also

CompareDelegate

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.

See also

CompareDelegate

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.

See also

CompareDelegate

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.

See also

CompareDelegate

Compare​Object


[Pure]
public static method CompareObject → (2)
<T ref : IComparable<T>>

in : T

First value.

in : T

Second value.

returns → int32

if in is less than in.
[=0] if in is equal to in.
[>0] if in is greater than in.

Compares the given nullable objects, where null appears first.

This method should not be used on the string type. Consider using StringUtil.Compare instead, if platform and culture independent behaviour is desired.

See also

CompareDelegate

Compare​Value


[Pure]
public static method CompareValue → (2)
<T val : IComparable<T>>

in : T

First value.

in : T

Second value.

returns → int32

if in is less than in.
[=0] if in is equal to in.
[>0] if in is greater than in.

Compares the given non-nullable values.

See also

CompareDelegate

Convert​Enum​To​Int


[Pure]
public static method ConvertEnumToInt → (1)<T>

enumItem in : T

The enum item.

returns → int64

The ordinal value.

Converts the given enum item to its ordinal value.

Convert​Int​To​Enum


[Pure]
public static method ConvertIntToEnum → (1)<T>

value in : int64

The ordinal value.

returns → T

The enum item.

Returns the enum item for the given ordinal value.

Create​Instance


[OwnerReturn]
public static method CreateInstance → ()<T>

returns → T

The object instance.

Creates a new instance of T using its default constructor.

Equals​Bag


[Pure]
public static method EqualsBag → (2)<T>

first in : IBagConst<T>

First collection.

second in : IBagConst<T>

Second collection.

returns → bool

true if both collections are equal, false if not.

Checks if the given collections are equal.

The given collection references are equal if one of the following conditions is true:

  • They refer to the same collection instance.

  • They are both null.

  • first in contains all elements of second in and vice versa, which includes the case that both collections are empty.

Equals​Bool


[Pure]
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​Default


[Pure]
public static method EqualsDefault → (2)<T>

in : T

First value.

in : T

Second value.

returns → bool

true if both values are equal, false if not.

Compares the given values.

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​Identity


[Pure]
public static method EqualsIdentity → (2)<T ref>

in : T

First object.

in : T

Second object.

returns → bool

true if in and in are the same object, false if not.

Compares the identity of the given objects.

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.

Equals​Object


[Pure]
public static method EqualsObject → (2)
<T ref : IEquatable<T>>

in : T

First nullable value.

in : T

Second nullable value.

returns → bool

true if both in and in are null or equal according to IEquatable, false if they are not equal.

Checks if the given nullable and equatable objects are equal.

Equals​Value


[Pure]
public static method EqualsValue → (2)
<T val : IEquatable<T>>

in : T

First non-nullable value.

in : T

Second non-nullable value.

returns → bool

true if in and in equal according to IEquatable, false if they are not equal.

Checks if the given non-nullable and equatable values are equal.

Equals​Vector


[Pure]
public static method EqualsVector → (2)<T>

first in : IVectorConst<T>

First list.

second in : IVectorConst<T>

Second list.

returns → bool

true if both lists are equal, false if not.

Checks if the given lists are equal.

The given list references are equal if one of the following conditions is true:

  • They refer to the same list instance.

  • They are both null.

  • The two lists contain the same sequence of elements, where element equality is determined by the IEquatable implementation of the given IVectorConst objects.

Hash​Code​Default


[Pure]
public static method HashCodeDefault → (1)<T>

in : T

The value.

returns → int32

The hash code.

Computes a hash code for the given value.

Hash​Code​Identity


[Pure]
public static method HashCodeIdentity → (1)<T ref>

value in : T

The object or null.

returns → int32

The hash value.

Computes a hash value for the identity of the given object.

Memory​Consumption​Of

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


[Pure]
public static method MemoryConsumptionOf11 → (1)<T ref>

things in : T [ ]

The things (assumed to be IMemoryConsumption objects).

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given array of things.


[Pure]
public static method MemoryConsumptionOf12 → (2)<T val>

things in : T [ ]

The things.

bytesPerElement in : int32

Memory consumption of each element in things in, in bytes.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given things.


[Pure]
public static method MemoryConsumptionOf13 → (1)<T ref>

things in : IEnumerable<T>

The things.

returns → int64

The estimated memory consumption, in bytes.

Returns the estimated memory consumption of the given things.

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.