Monday, February 17, 2020

Rotate Array Left N-times c#

Rotate Array Left N-times c#:

public static int[] RotateArrayLeft(int[] ins, int startindex = 1)
 {
  if (ins == null || ins.Length == 0) { return ins; }
  var outs = new int[ins.Length];
  //Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length):
  Array.Copy(ins, startindex, outs, 0, ins.Length - startindex);
  var q = new Queue(ins);
  for (int i = outs.Length - startindex; i < outs.Length; i++)
  {
   outs[i] = q.Dequeue();
  }

  return outs;
 }

more at siccolo blurbs

No comments:

Exception handling -> "bubble up

Exception handling -> "bubble up" Exception handling (#1) try { ... // might fail ... } ca...