linkedList function

Node? linkedList(
  1. dynamic data,
  2. int start,
  3. int end,
  4. int dim,
  5. bool clockwise,
)

Implementation

Node? linkedList(data, int start, int end, int dim, bool clockwise) {
  int i;
  Node? last;

  if (clockwise == (signedArea(data, start, end, dim) > 0)) {
    for (i = start; i < end; i += dim) {
      last = insertNode(i, data[i], data[i + 1], last);
    }
  } else {
    for (i = end - dim; i >= start; i -= dim) {
      last = insertNode(i, data[i], data[i + 1], last);
    }
  }

  if (last != null && equals(last, last.next)) {
    removeNode(last);
    last = last.next;
  }

  return last;
}