downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

SplMaxHeap::compare> <SplHeap::valid
[edit] Last updated: Fri, 17 May 2013

view this page in

La classe SplMaxHeap

(PHP 5 >= 5.3.0)

Introduction

La classe SplMaxHeap fournit l'interface pour un tas, et conserve le maximum sur le haut.

Synopsis de la classe

SplMaxHeap extends SplHeap implements Iterator , Countable {
/* Méthodes */
int compare ( mixed $value1 , mixed $value2 )
/* Méthodes héritées */
abstract int SplHeap::compare ( mixed $value1 , mixed $value2 )
int SplHeap::count ( void )
mixed SplHeap::current ( void )
mixed SplHeap::extract ( void )
void SplHeap::insert ( mixed $value )
bool SplHeap::isEmpty ( void )
mixed SplHeap::key ( void )
void SplHeap::next ( void )
void SplHeap::rewind ( void )
mixed SplHeap::top ( void )
bool SplHeap::valid ( void )
}

Sommaire



add a note add a note User Contributed Notes SplMaxHeap - [1 notes]
up
1
MuLoT [ojousset49 at yahoo dot fr]
2 years ago
SplMaxHeap simple example with integer values...

&lt;?php
class MySimpleHeap extends SplHeap
{
    public function  compare( $value1, $value2 ) {
        return ( $value1 - $value2 );
    }
}

$obj = new MySimpleHeap();
$obj-&gt;insert( 4 );
$obj-&gt;insert( 8 );
$obj-&gt;insert( 1 );
$obj-&gt;insert( 0 );

foreach( $obj as $number ) {
    echo $number.\&quot;\\n\&quot;;
}

/*
    Output display :
    8
    4
    1
    0
*/
?&gt;

 
show source | credits | stats | sitemap | contact | advertising | mirror sites