Skip to content

Commit

Permalink
Merge pull request wangzheng0822#267 from IceBlackTea/master
Browse files Browse the repository at this point in the history
修复 size getter 方法导致的死循环
  • Loading branch information
wangzheng0822 authored Mar 14, 2019
2 parents e0cd3f7 + cf40a77 commit d97d22a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion swift/08_stack/StackBasedOnLinkedList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d97d22a

Please sign in to comment.