algo/swift/08_stack/Browser.swift
Jiandan 42426ba5a8 [swift][06_linkedlist][add]
[swift][07_linkedlist][add]
[swift][08_stack][add]
2018-10-30 11:07:29 +08:00

28 lines
585 B
Swift

//
// Created by Jiandan on 2018/10/12.
// Copyright (c) 2018 Jiandan. All rights reserved.
//
import Foundation
struct Page {
/// url
private var forwardArray = [String]()
/// 退 url
private var backArray = [String]()
var currentURL: String? { return forwardArray.last }
init(url: String) {
forwardArray.append(url)
}
///
mutating func goForward(url: String) {
forwardArray.append(url)
}
/// 退
mutating func goBack() {
backArray.append(forwardArray.popLast()!)
}
}