TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class CollectionsUtil in Tinman.Core.Collections

Helper class for dealing with arrays and generic lists.

static class CollectionsUtil with <T>  

Public / Methods

ArrayClear

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

public static method ArrayClear (T[] array, int32 offset = 0, int32 count = -1)
params array [not-null] The array to clear.
  offset [>=0] Offset to first element in array to clear. Defaults to 0.
  count [>=-1] Number of elements in array to clear. If -1, all remaining elements will be cleared. Defaults to -1.

ArrayCopy

Copies elements from one array to another.

public static method ArrayCopy ([] T[] source, int32 sourceIdx, [] T[] target, int32 targetIdx, int32 count)
params source [not-null] The source array.
  sourceIdx [>=0] Index of first element in source to copy.
  target [not-null] The target array.
  targetIdx [>=0] Index of first element in target to write.
  count [>=0] Total number of array elements to copy.

ArrayOf

Creates an array of the given elements.

public static method ArrayOf (IEnumerable<T> elements)
type T[]
params elements The elements.
returns The array or null iff elements is null.

BinarySearch

Runs a binary search for value in the given array.

[Pure]
public static method BinarySearch (T value, T[] array, CompareDelegate<T> comparer)
type int32
params value The value to search.
  array [not-null] The array (must be sorted in ascending order).
  comparer [not-null] The compare to use.
returns Index of the array element that equals value. If the value has not been found in the array, -idx-1 is returned, where idx is the insertion index of value.

Runs a binary search for value in the given array.

[Pure]
public static method BinarySearch (T value, [] T[] array, int32 offset, int32 count, CompareDelegate<T> compare)
type int32
params value The value to search.
  array [not-null] The array (must be sorted in ascending order).
  offset [>=0] Index of first array element to search.
  count [>=0] Length of array range to search.
  compare [not-null] The compare to use.
returns Index of the array element that equals value. If the value has not been found in the array, -idx-1 is returned, where idx is the insertion index of value.

Choose

Chooses one of the four values by the given index.

[Pure]
public static method Choose (int32 idx, T idx0, T idx1, T idx2, T idx3)
type T
params idx [0..3] The index.
  idx0 The value to return if idx is 0.
  idx1 The value to return if idx is 1.
  idx2 The value to return if idx is 2.
  idx3 The value to return if idx is 3.
returns The value chosen by idx.

EqualsArray

Checks if the given arrays are equal.

[Pure]
public static method EqualsArray (T[] first, T[] second, EqualsDelegate<T> equals = null)
type bool
params first The first array or null.
  second The second array or null.
  equals Optional equality compare.
returns true if both arrays contain the same elements, false if not.

Remarks:

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

EqualsCollection

Checks if the given collections are equal.

[Pure]
public static method EqualsCollection (IBagConst<T> first, IBagConst<T> second)
type bool
params first First collection.
  second Second collection.
returns true if both collections are equal, false if not.

Remarks:

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

EqualsList

Checks if the given lists are equal.

[Pure]
public static method EqualsList (IVectorConst<T> first, IVectorConst<T> second)
type bool
params first First list.
  second Second list.
returns true if both lists are equal, false if not.

Remarks:

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

GrowTo

Grows the given array to the specified length.

[Pure]
public static method GrowTo (T[] array, int32 count, int64 length)
type T[]
params array The array to grow.
  count [>=0] Number of valid elements in array.
  length [>=0] New array length.
returns [not-null] The grown array.

GrowUntil

Proportionally grows the given array until its length is equal to or greater than the specified length.

[Pure]
public static method GrowUntil (T[] array, int32 count, int64 length)
type T[]
params array The array to grow.
  count [>=0] Number of valid elements in array.
  length [>=0] New array length (minimum).
returns [not-null] The grown array.

Remarks:

The new array length is computed as follows:

newLength := max(length, currentLength * 5 / 4)
where newLength is the length of the returned array, length is the value of the length parameter and currentLength is the length of the given array.

If count is greater than zero, all array elements in the range [0..count-1] are copied from the given array to the newly allocated one.

Sort

Sorts the given array range.

public static method Sort (T[] array, CompareDelegate<T> comparer)
type T[]
params array [not-null] The array that holds the range to sort.
  comparer [not-null] The compare to use.
returns [not-null] The sorted input array.

Remarks:

The method uses an unstable hybrid quicksort (median-3 pivot) / insertion sort algorithm.


Sorts the given array range.

public static method Sort (T[] array, int32 offset, int32 count, CompareDelegate<T> comparer)
type T[]
params array [not-null] The array that holds the range to sort.
  offset [>=0] Offset into array to first element in range.
  count [>=0] Total number of elements in range.
  comparer [not-null] The compare to use.
returns [not-null] The sorted input array.

Remarks:

The method uses an unstable hybrid quicksort (median-3 pivot) / insertion sort algorithm.

Sort4

Sorts the given values.

[Pure]
public static method Sort4 (T d0, T d1, T d2, T d3, CompareDelegate<T> compare)
type Vec4I
params d0 First value to sort.
  d1 Second value to sort.
  d2 Third value to sort.
  d3 Fourth value to sort.
  compare [not-null] The compare to use.
returns The sort order:
X: sort order index of d0
Y: sort order index of d1
Z: sort order index of d2
W: sort order index of d3

SortIndex

Sorts the given array range.

public static method SortIndex (T[] array, int32[] indices, CompareDelegate<T> comparer)
type T[]
params array [not-null] The array that holds the elements to compare. This array will not be modified.
  indices [not-null] The array indices to be sorted (the values in this array are used to access array).
  comparer [not-null] The compare to use.
returns [not-null] The sorted input array.

Remarks:

The method uses a stable hybrid quicksort (median-3 pivot) / insertion sort algorithm.


Sorts the given array range.

public static method SortIndex (T[] array, int32[] indices, int32 offset, int32 count, CompareDelegate<T> comparer)
type T[]
params array [not-null] The array that holds the elements to compare. This array will not be modified.
  indices [not-null] The array indices to be sorted (the values in this array are used to access array).
  offset [>=0] Offset into array to first element in range.
  count [>=0] Total number of elements in range.
  comparer [not-null] The compare to use.
returns [not-null] The sorted input array.

Remarks:

The method uses a stable hybrid quicksort (median-3 pivot) / insertion sort algorithm.

SortList

Sorts the given list range.

public static method SortList (IVector<T> list, CompareDelegate<T> comparer)
type IVector<T>
params list [not-null] The list that holds the range to sort.
  comparer [not-null] The compare to use.
returns [not-null] The sorted input list.

Remarks:

The method uses an unstable hybrid quicksort (median-3 pivot) / insertion sort algorithm.


Sorts the given list range.

public static method SortList (IVector<T> list, int32 offset, int32 count, CompareDelegate<T> comparer)
type IVector<T>
params list [not-null] The list that holds the range to sort.
  offset [>=0] Offset into list to first element in range.
  count [>=0] Total number of elements in range.
  comparer [not-null] The compare to use.
returns [not-null] The sorted input list.

Remarks:

The method uses an unstable hybrid quicksort (median-3 pivot) / insertion sort algorithm.

Wrap

Returns a new list that initially holds the given element.

[Pure]
public static method Wrap (T element)
type IVectorConst<T>
params element The list element.
returns [not-null] The list.

Returns an IVectorConst object that wraps the given array.

public static method Wrap (T[] array, EqualsDelegate<T> equals = null)
type IArrayVector<T>
params array The array to wrap.
  equals The equality delegate.
returns The list object or null if array is null.

Remarks:

The list will use the given array, no elements will be copied.