Fixing the size getter leads to infinite loop.
This commit is contained in:
parent
e0cd3f758d
commit
cf40a77268
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user