| 1 |
|
<?php |
| 2 |
|
/** |
| 3 |
|
* Xyster Framework |
| 4 |
|
* |
| 5 |
|
* LICENSE |
| 6 |
|
* |
| 7 |
|
* This source file is subject to the new BSD license that is bundled |
| 8 |
|
* with this package in the file LICENSE.txt. |
| 9 |
|
* It is also available through the world-wide-web at this URL: |
| 10 |
|
* http://www.opensource.org/licenses/bsd-license.php |
| 11 |
|
* If you did not receive a copy of the license and are unable to |
| 12 |
|
* obtain it through the world-wide-web, please send an email |
| 13 |
|
* to xyster@devweblog.org so we can send you a copy immediately. |
| 14 |
|
* |
| 15 |
|
* @category Xyster |
| 16 |
|
* @package Xyster_Collection |
| 17 |
|
* @copyright Copyright (c) 2007 Irrational Logic (http://devweblog.org) |
| 18 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 19 |
|
*/ |
| 20 |
|
/** |
| 21 |
|
* Xyster_Collection_Set_Abstract |
| 22 |
|
*/ |
| 23 |
1 |
require_once 'Xyster/Collection/Set/Abstract.php'; |
| 24 |
|
/** |
| 25 |
|
* No-duplicate collection whose elements can be reordered |
| 26 |
|
* |
| 27 |
|
* @category Xyster |
| 28 |
|
* @package Xyster_Collection |
| 29 |
|
* @copyright Copyright (c) 2007 Irrational Logic (http://devweblog.org) |
| 30 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 31 |
|
*/ |
| 32 |
|
class Xyster_Collection_Set_Sortable extends Xyster_Collection_Set_Abstract |
| 33 |
|
{ |
| 34 |
|
/** |
| 35 |
|
* Creates a new set |
| 36 |
|
* |
| 37 |
|
* @param Xyster_Collection_Interface $set The values to add to this set |
| 38 |
|
*/ |
| 39 |
|
public function __construct( Xyster_Collection_Interface $set = null ) |
| 40 |
|
{ |
| 41 |
14 |
if ( $set ) { |
| 42 |
1 |
$this->merge($set); |
| 43 |
1 |
} |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
/** |
| 47 |
|
* Sorts the collection according to the values in the elements |
| 48 |
|
* |
| 49 |
|
* @param Xyster_Collection_Comparator_Interface $comparator The comparator |
| 50 |
|
*/ |
| 51 |
|
public function sort( Xyster_Collection_Comparator_Interface $comparator ) |
| 52 |
|
{ |
| 53 |
10 |
usort($this->_items, array($comparator, 'compare')); |
| 54 |
|
} |
| 55 |
|
} |