File: src/functions.php

Recommend this page to a friend!
  Classes of Carlos Artur Curvelo da Matos  >  PHP DS Functional  >  src/functions.php  >  Download  
File: src/functions.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP DS Functional
Convert values stored in PHP data structures
Author: By
Last change:
Date: 4 months ago
Size: 1,167 bytes
 

Contents

Class file image Download
<?php

function vector()
{
   
$params = func_get_args();
   
$array = [];

    foreach (
$params as $param) {
       
$array[] = $param;
    }

    return new \
Ds\Vector($array);
}

function
set()
{
   
$params = func_get_args();
   
$array = [];

    foreach (
$params as $param) {
       
$array[] = $param;
    }

    return new \
Ds\Set($array);
}

function
stack()
{
   
$params = func_get_args();
   
$array = [];

    foreach (
$params as $param) {
       
$array[] = $param;
    }

    return new \
Ds\Stack($array);
}

function
queue()
{
   
$params = func_get_args();
   
$array = [];

    foreach (
$params as $param) {
       
$array[] = $param;
    }

    return new \
Ds\Queue($array);
}

function
map()
{
   
$params = func_get_args();
   
$array = [];

    foreach (
$params as $param) {
       
$array[] = $param;
    }

    return new \
Ds\Map($array);
}

function
deque()
{
   
$params = func_get_args();
   
$deque = new \Ds\Deque();

    foreach(
$params as $param) {
       
$deque->push($param);
    }

    return
$deque;
}

function
pqueue()
{
   
$params = func_get_args();
   
$pqueue = new \Ds\PriorityQueue();
   
$j = count($params);
   
//var_dump($params);

   
for($i = 0; $i < $j; $i++) {
        if(
$i % 2 == 0) {
           
$pqueue->push($params[$i], $params[$i + 1]);
        }
    }

    return
$pqueue;
}

For more information send a message to info at phpclasses dot org.