/// <summary> /// Winds a flat array onto current using the IWinder object. /// The IWinder object is automatically reset before winding. /// IWinder object and current matrix should be have the same dimension (i.e. row count and column count). /// </summary> /// <param name="winder">An IWinder object. Row and column count should match with current matrix.</param> /// <param name="flatMatrix">A single-dimension matrix. Element count should match with current matrix.</param> public void windFromArray(IWinder winder, T[] flatMatrix) { if (flatMatrix.Length != this.ElementCount) { throw new ArgumentException("The element count of the current matrix and the element count of the flat matrix must match."); } winder.reset(); for (int i = 0; i < this.ElementCount; i++) { this[winder.getNextIndexPair()] = flatMatrix[i]; } }
// ------------------------------------------------------------------------------ // -----------------------------WINDING capabilities----------------------------- public T[] unwindToArray(IWinder winder) { T[] temp = new T[this.ElementCount]; winder.reset(); for (int i = 0; i < this.ElementCount; i++) { temp[i] = this[winder.getNextIndexPair()]; } return(temp); }