entriesToInts static method

List<int> entriesToInts(
  1. List<Float64x2> list
)

Implementation

static List<int> entriesToInts(List<Float64x2> list) {
  final lastEntryIndex = list.length - 1;
  var entryIndex = 0;
  var entry = list.first;
  var entryCursor = -1;
  var valueCursor = -1;

  var fs = List.generate(list.length * 2, (i) {
    assert(++valueCursor == i);

    switch (++entryCursor) {
      case 0:
        {
          return entry.x.toInt();
        }
      case 1:
        {
          var y = entry.y;
          if (entryIndex < lastEntryIndex) {
            entry = list[++entryIndex];
            entryCursor = -1;
          }
          return y.toInt();
        }
      default:
        throw StateError('Invalid entryCursor: $entryCursor');
    }
  });

  return fs;
}