Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
- (ListNode *)next {
if (_next) {
ListNode *nextCopy = [[ListNode alloc] init];
nextCopy.name = _next.name;
nextCopy.next = _next.next;
return nextCopy;
} else {
return nil;
}
}
- (NSUInteger)length_unsafe {
return [[self class] lengthOfListWithHead_unsafe:self count:0];
}
+ (NSUInteger)lengthOfListWithHead_unsafe:(ListNode *)node count:(NSUInteger)count {
if (!node)
return count;
else {
__unsafe_unretained ListNode *next = node.next;
return [self lengthOfListWithHead_unsafe:next count:(count + 1)];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.