forEach method

void forEach(
  1. void action(
    1. E entry
    )
)
override

Call action with each entry in this linked list.

It's an error if action modifies the linked list.

Implementation

void forEach(void action(E entry)) {
  int modificationCount = _modificationCount;
  if (isEmpty) return;

  E current = _first!;
  do {
    action(current);
    if (modificationCount != _modificationCount) {
      throw ConcurrentModificationError(this);
    }
    current = current._next!;
  } while (!identical(current, _first));
}