How to implement Generic stack in iOS/Swift
//----------------------Generic Stack----------------------//
struct Stack<T> {
private var stackArr: [T]
init() { stackArr = [] }
var isEmpty : Bool { return stackArr.count == 0 }
var tos : T? { return isEmpty ? nil : stackArr.last }
mutating func push(_ data: T){ stackArr.append(data) }
mutating func pop() { if isEmpty { return; }; stackArr.removeLast(); }
}
//----------------------Generic Stack----------------------//
Sign up here with your email
ConversionConversion EmoticonEmoticon