PHP Doku:: The SplMaxHeap class - class.splmaxheap.html

Verlauf / Chronik / History: (30) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenStandard PHP Library (SPL)DatenstrukturenThe SplMaxHeap class

Ein Service von Reinhard Neidl - Webprogrammierung.

Datenstrukturen

<<SplHeap::valid

SplMaxHeap::compare>>


UnterSeiten:

The SplMaxHeap class

Einführung

The SplMaxHeap class provides the main functionalities of a heap, keeping the maximum on the top.

Klassenbeschreibung

SplMaxHeap extends SplHeap implements Iterator , Countable {
/* Methoden */
void compare ( mixed $value1 , mixed $value2 )
/* Geerbte Methoden */
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 )
}

Inhaltsverzeichnis


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
MuLoT [ojousset49 at yahoo dot fr]
17.12.2010 14:50
SplMaxHeap simple example with integer values...

<?php
class MySimpleHeap extends SplMaxHeap
{
    public function 
compare( $value1, $value2 ) {
        return (
$value1 - $value2 );
    }
}

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

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

/*
    Output display :
    8
    4
    1
    0
*/
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)