Fixing the size getter leads to infinite loop.

This commit is contained in:
Xummer 2019-03-11 23:12:30 +08:00 committed by GitHub
parent e0cd3f758d
commit cf40a77268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,8 +14,10 @@ struct StackBasedOnLinkedList<Element>: Stack {
var size: Int { var size: Int {
var count = 0 var count = 0
while head.next != nil { var cur = head.next
while cur != nil {
count += 1 count += 1
cur = cur?.next
} }
return count return count
} }