//
//  SVDWStack.swift
//  SwiftProject
//
//  Created by aaa on 2024/5/23.
//

import Foundation
struct SVDWStack<Element: Equatable> {
    private var storage: [Element] = []

    mutating func push(_ element: Element) {
        storage.append(element)
    }

    mutating func pop() -> Element? {
        return storage.popLast()
    }

    func top() -> Element? {
        return storage.last
    }

    func isEmpty() -> Bool {
        return storage.isEmpty
    }

    mutating func clear() {
        storage.removeAll()
    }
}
