PHP 實現佇列類 僅供參考

2021-05-26 22:25:25 字數 1292 閱讀 6983

實際開發中需要用到 php 類似佇列的功能 於是乎 寫了下面的類 寫的比較倉卒 有bug  歡迎email 我,學習交流僅供參考。

/**

* php class for queue

* @author [email protected]

*/class queue

/*** @desc start queue

* @param string  $param  new queue element

*/public function run($param)

$currentlength=$this->countqueue();  //count  the  queue length

echo $this->length;

if($currentlength<$this->length&&$this->length>0) else if($this->length==0)

else

$this->queadd($param);

}return $this->queue;

}/**

* string like this "22,23,24"  convert to array to do queue

* @param string $string

* @param string $delimiter

*/public function strtoque ()

else

}/**

* insert $node into queue

* @param string $node

*/private function queadd($node)

private function queremove()

private function countqueue()

function __destruct()

}//example

/*$str='88|89|90';

$obj=new queue ($str);

$obj->length=8; // 佇列元素長度

$obj->delimiter='|'; //如果佇列是字串,則元素直接的分隔符為|

$a=$obj->run('91'); //要新增到佇列中的元素

$a=$obj->run('92');

$a=$obj->run('93');

$a=$obj->run('94');

print_r($a);*/

?>

ITIL,僅供參考!

上週去某上市公司面試乙個itil產品技術經理的崗位,前一輪面試已經談了不少管理方面的事情了,這次主要集中在談itil的知識。該公司本身在做hp等廠家的itil類產品的 自己也開發了一套itil軟體。在面談過程中,該公司的面試人員對我原先服務的理想科技公司entegor ieai 產品在光大銀行it服...

汽車租賃,僅供參考適應參考。

汽車租賃,僅供參考適應參考。汽車業務類 public class vehicleoperation 租車 簡單工廠模式 引數 品牌 座位數 型號 客車 品牌 座位數 轎車 品牌 0 型號 public vehicle rentvehicle string brand,int seatcount,st...

鏈式佇列(c),插入排序僅供參考

c define crt secure no warnings include include include include stacknode.h define n 100 typedef char datatype 佇列問題 struct queue queue initqueue queue...