SHARE
TWEET

Untitled

a guest Sep 11th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var max:Int!
  2. var data:[Any] = []
  3.  
  4. init(_ max:Int) {
  5.     self.max = max
  6. }
  7.  
  8. func enqueue(_ obj:Any) -> Bool {
  9.     if data.count > self.max - 1 {
  10.         return false
  11.     }
  12.     data.append(obj)
  13.     return true
  14. }
  15.  
  16. func dequeue() -> Any? {
  17.     if data.count > 0 {
  18.         let obj = data[0]
  19.         data.remove(at: 0)
  20.         return obj
  21.     }
  22.     return nil
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top