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: Thu, 23 May 2013

view this page in

la clase SplMaxHeap

(PHP 5 >= 5.3.0)

Introducción

La clase SplMaxHeap proporciona las principales funcionalidades de una pila, manteniendo el máximo en la parte superior.

Sinopsis de la Clase

SplMaxHeap extends SplHeap implements Iterator , Countable {
/* Métodos */
int compare ( mixed $value1 , mixed $value2 )
/* Métodos heredados */
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 )
}

Tabla de contenidos

  • SplMaxHeap::compare — Compara elementos con el fin de colocarlos correctamente en el montón en la parte de arriba


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 | sitemap | contact | advertising | mirror sites