SHARE
TWEET

Untitled

a guest Aug 25th, 2019 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function splQueueMerge() {
  2.     $args = func_num_args();
  3.    
  4.     if( $args == 0  ) {
  5.         return new SplQueue();
  6.     }
  7.    
  8.     $buffer = func_get_arg(0);
  9.  
  10.     if (!($buffer instanceof SplQueue)) {
  11.         throw new \RuntimeException();
  12.     }
  13.  
  14.     $buffer->rewind();
  15.        
  16.     for ($i = 1; $i < $args; $i++) {
  17.         $queue = func_get_arg($i);
  18.  
  19.         if (!($queue instanceof SplQueue)) {
  20.             throw new \RuntimeException();
  21.         }
  22.  
  23.         for($queue->rewind(); $queue->valid(); $queue->next()) {
  24.             $buffer->enqueue($queue->current());
  25.         }
  26.     }
  27.    
  28.     return $buffer;
  29. }
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