Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var max:Int!
- var data:[Any] = []
- init(_ max:Int) {
- self.max = max
- }
- func enqueue(_ obj:Any) -> Bool {
- if data.count > self.max - 1 {
- return false
- }
- data.append(obj)
- return true
- }
- func dequeue() -> Any? {
- if data.count > 0 {
- let obj = data[0]
- data.remove(at: 0)
- return obj
- }
- return nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement