note 101390 added to class.splmaxheap

From: Date: Tue, 14 Dec 2010 12:57:53 +0000
Subject: note 101390 added to class.splmaxheap
Groups: php.notes 
Request: Send a blank email to php-notes+get-174902@lists.php.net to get a copy of this message
<?php // File Heap with max size on top class UserFiles extends SplMaxHeap { public function compare( SplFileInfo $value1, SplFileInfo $value2 ) { return ( $value1->getSize() - $value2->getSize() ); } } $obj = new UserFiles(); $obj->insert( new SplFileInfo( 'path/to/my/file/1' ) ); // 3.9 Mo $obj->insert( new SplFileInfo( 'path/to/my/file/2' ) ); // 9.8 Mo $obj->insert( new SplFileInfo( 'path/to/my/file/3' ) ); // 0.8 Mo $obj->insert( new SplFileInfo( 'path/to/my/file/4' ) ); // 16 Mo foreach( $obj as $file ) { echo $file->getPathname()."\n"; } /* Output display : path/to/my/file/4 path/to/my/file/2 path/to/my/file/1 path/to/my/file/3 */ ?> ---- Server IP: 89.31.146.176 Probable Submitter: 88.162.41.190 ---- Manual Page -- http://www.php.net/manual/en/class.splmaxheap.php Edit -- https://master.php.net/note/edit/101390 Del: integrated -- https://master.php.net/note/delete/101390/integrated Del: useless -- https://master.php.net/note/delete/101390/useless Del: bad code -- https://master.php.net/note/delete/101390/bad+code Del: spam -- https://master.php.net/note/delete/101390/spam Del: non-english -- https://master.php.net/note/delete/101390/non-english Del: in docs -- https://master.php.net/note/delete/101390/in+docs Del: other reasons-- https://master.php.net/note/delete/101390 Reject -- https://master.php.net/note/reject/101390 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174902) next »