您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php中SPL常用的数据结构详解

2024/4/13 17:09:01发布11次查看
本文主要和大家分享php中spl常用的数据结构详解,主要以代码的方式和大家分享,希望能帮助到大家。
本文栈【先进后出】
<span style="font-size:18px;">$stack = new splstack(); $stack->push('data1'); $stack->push('data2'); $stack->push('data3'); echo $stack->pop(); //输出结果为 //data3</span><span style="font-size:24px;font-weight: bold;"> </span>
2.队列【先进先出 后进后出】
<span style="font-size:18px;">$queue = new splqueue(); $queue->enqueue("data1"); $queue->enqueue("data2"); $queue->enqueue("data3"); echo $queue->dequeue(); //输出结果为 //data1</span>
3.堆
<span style="font-size:18px;">$heap = new splminheap(); $heap->insert("data1"); $heap->insert("data2"); echo $heap->extract(); //输出结果为 //data1</span>
4.固定尺寸数组
<span style="font-size:18px;">$array = new splfixedarray(5); $array[0]=1; $array[3]=3; $array[2]=2; var_dump($array); //输出结果为 // object(splfixedarray)[1] // public 0 => int 1 // public 1 => null // public 2 => int 2 // public 3 => int 3 // public 4 => null</span>
相关推荐:
js数据结构和算法之数组和散列表详解
javascript数据结构与算法详解
php实现栈数据结构和括号匹配
以上就是php中spl常用的数据结构详解的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product