Merge pull request #267 from IceBlackTea/master
修复 size getter 方法导致的死循环
This commit is contained in:
commit
d97d22ad6d
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user