len
Iterate over all nodes, returning the count.
This operation is O(N). Consider tracking the length separately rather than computing it.
Function parameters
Parameters
This struct contains only a next pointer and not any data payload.
Types
- Node
- This struct contains only a next pointer and not any data payload.
Functions in this namespace
Functions
Source
Implementation
pub fn len(list: SinglyLinkedList) usize {
if (list.first) |n| {
return 1 + n.countChildren();
} else {
return 0;
}
}