Maths.IndexMap

References
public sealed class Maths.IndexMap : IEquatable<Maths.IndexMap>
An integer array of length N containing all the integers from 0 to N-1. This map encodes a specific (re)ordering of items in an array. Grasshopper uses index mapping instead of in-place sorting so that a specific ordering can be cheaply applied to more than one collection.

Constructors

IndexMap

#
public IndexMap(params int[] map)
Create a new index map. The validity of the map is not tested. If you are suspicious about a map you must call Validate() yourself.
map (params int[])

Properties

Array

#
public int[] Array { get; }
Return the internal array. Note that this does not create a copy of the array, so changes made to the returned instance will modify this index map. Do so at your own peril.

Length

#
public int Length { get; }
Gets the size of this map.

Indexers

this[]

#
public int this[int index] { get; }
Gets the mapping at the given index.
index (int)

Methods

Apply<T>

#
public T[] Apply<T>(T[] array)
Apply this mapping to an existing array.
array (T[])

Combine

#
public static Maths.IndexMap Combine(params IndexMap[] maps)
Combine multiple maps into a single map which encodes the ordering of both.
maps (params Maths.IndexMap[])

Equals

#
public bool Equals(IndexMap other)
other (Maths.IndexMap)

Equals

#
public override bool Equals(object obj)
obj (object)
Object.Equals

GetHashCode

#
public override int GetHashCode()

Identity

#
public static Maths.IndexMap Identity(int count)
Create an identity mapping of the given length.
count (int)

Invert

#
public Maths.IndexMap Invert()
Invert the index map. This can also be used to create an array of integers which can be used as sorting keys.

Validate

#
public bool Validate(out string reason)
Ensure that each integers from zero to count-1 appears exactly once in this mapping.
reason (out string)