Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function splQueueMerge() {
- $args = func_num_args();
- if( $args == 0 ) {
- return new SplQueue();
- }
- $buffer = func_get_arg(0);
- if (!($buffer instanceof SplQueue)) {
- throw new \RuntimeException();
- }
- $buffer->rewind();
- for ($i = 1; $i < $args; $i++) {
- $queue = func_get_arg($i);
- if (!($queue instanceof SplQueue)) {
- throw new \RuntimeException();
- }
- for($queue->rewind(); $queue->valid(); $queue->next()) {
- $buffer->enqueue($queue->current());
- }
- }
- return $buffer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement