Merge pull request #267 from IceBlackTea/master

修复 size getter 方法导致的死循环
This commit is contained in:
wangzheng0822 2019-03-14 11:15:56 +08:00 committed by GitHub
commit d97d22ad6d
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 count = 0
while head.next != nil {
var cur = head.next
while cur != nil {
count += 1
cur = cur?.next
}
return count
}