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