SplMaxHeap / SplMInHeap 大排序

最后更新于:2022-04-02 02:26:10

[TOC] ## 实例 ### SplMaxHelp 从大到小 ``` $obj = new SplMaxHeap(); $obj->insert( 4 ); $obj->insert( 8 ); $obj->insert( 1 ); $obj->insert( 0 ); foreach( $obj as $number ) { echo $number."\n"; } //8 //4 //1 //0 ``` ### SplMinHelp 从小到大 ``` $obj = new SplMinHeap(); $obj->insert( 4 ); $obj->insert( 8 ); $obj->insert( 1 ); $obj->insert( 0 ); foreach( $obj as $number ) { echo $number."\n"; } //0 //1 //4 //8 ```
';