pub fn len(list: SinglyLinkedList) usize
Iterate over all nodes, returning the count.
This operation is O(N). Consider tracking the length separately rather than computing it.
list: SinglyLinkedList
113 114 115 116 117 118 119
pub fn len(list: SinglyLinkedList) usize { if (list.first) |n| { return 1 + n.countChildren(); } else { return 0; } }
Iterate over all nodes, returning the count.
This operation is O(N). Consider tracking the length separately rather than computing it.