complement method

List<Node<T>> complement(
  1. List<Node<T>> other, {
  2. bool includeThis = true,
  3. bool includeOther = true,
})

Implementation

List<Node<T>> complement(
  List<Node<T>> other, {
  bool includeThis = true,
  bool includeOther = true,
}) {
  if (identical(this, other)) return [];

  if (isEmpty) return includeOther ? other.toList() : [];
  if (other.isEmpty) return includeThis ? toList() : [];

  var complement = [
    if (includeThis) ...where((e) => !other.contains(e)),
    if (includeOther) ...other.where((e) => !contains(e)),
  ];

  return complement;
}