ElggPriorityList Class Reference

List of all members.

Public Member Functions

 __construct (array $elements=array())
 Create a new priority list.
 add ($element, $priority=null, $exact=false)
 Adds an element to the list.
 remove ($element, $strict=false)
 Removes an element from the list.
 move ($element, $new_priority, $strict=false)
 Move an existing element to a new priority.
 getElements ()
 Returns the elements.
 sort ($callback=null)
 Sort the elements optionally by a callback function.
 getNextPriority ($near=0)
 Returns the next priority available.
 getPriority ($element, $strict=false)
 Returns the priority of an element if it exists in the list.
 getElement ($priority)
 Returns the element at $priority.
 contains ($element, $strict=false)
 Returns if the list contains $element.
 rewind ()
 Iterator.
 current ()
 PHP Iterator Interface.
 key ()
 PHP Iterator Interface.
 next ()
 PHP Iterator Interface.
 valid ()
 PHP Iterator Interface.
 count ()
 Countable interface.

Detailed Description

Definition at line 95 of file ElggPriorityList.php.


Constructor & Destructor Documentation

ElggPriorityList::__construct ( array $  elements = array()  ) 

Create a new priority list.

Parameters:
array $elements An optional array of priorities => element

Definition at line 110 of file ElggPriorityList.php.


Member Function Documentation

ElggPriorityList::add ( element,
priority = null,
exact = false 
)

Adds an element to the list.

Warning:
This returns the priority at which the element was added, which can be 0. Use !== false to check for success.
Parameters:
mixed $element The element to add to the list.
mixed $priority Priority to add the element. In priority collisions, the original element maintains its priority and the new element is to the next available slot, taking into consideration all previously registered elements. Negative elements are accepted.
bool $exact unused
Returns:
int The priority of the added element.

Definition at line 133 of file ElggPriorityList.php.

ElggPriorityList::contains ( element,
strict = false 
)

Returns if the list contains $element.

Parameters:
mixed $element The element to check.
bool $strict Use strict checking?
Returns:
bool

Definition at line 288 of file ElggPriorityList.php.

ElggPriorityList::count (  ) 

Countable interface.

See also:
Countable::count()
Returns:
int

Definition at line 363 of file ElggPriorityList.php.

ElggPriorityList::current (  ) 

PHP Iterator Interface.

See also:
Iterator::current()
Returns:
mixed

Definition at line 318 of file ElggPriorityList.php.

ElggPriorityList::getElement ( priority  ) 

Returns the element at $priority.

Parameters:
int $priority The priority
Returns:
mixed The element or false on fail.

Definition at line 277 of file ElggPriorityList.php.

ElggPriorityList::getElements (  ) 

Returns the elements.

Returns:
array

Definition at line 196 of file ElggPriorityList.php.

ElggPriorityList::getNextPriority ( near = 0  ) 

Returns the next priority available.

Parameters:
int $near Make the priority as close to $near as possible.
Returns:
int

Definition at line 248 of file ElggPriorityList.php.

ElggPriorityList::getPriority ( element,
strict = false 
)

Returns the priority of an element if it exists in the list.

Warning:
This can return 0 if the element's priority is 0.
Parameters:
mixed $element The element to check for.
bool $strict Use strict checking?
Returns:
mixed False if the element doesn't exists, the priority if it does.

Definition at line 267 of file ElggPriorityList.php.

ElggPriorityList::key (  ) 

PHP Iterator Interface.

See also:
Iterator::key()
Returns:
int

Definition at line 329 of file ElggPriorityList.php.

ElggPriorityList::move ( element,
new_priority,
strict = false 
)

Move an existing element to a new priority.

Parameters:
mixed $element The element to move
int $new_priority The new priority for the element
bool $strict Whether to check the type of the element match
Returns:
bool

Definition at line 173 of file ElggPriorityList.php.

ElggPriorityList::next (  ) 

PHP Iterator Interface.

See also:
Iterator::next()
Returns:
mixed

Definition at line 340 of file ElggPriorityList.php.

ElggPriorityList::remove ( element,
strict = false 
)

Removes an element from the list.

Warning:
The element must have the same attributes / values. If using $strict, it must have the same types. array(10) will fail in strict against array('10') (str vs int).
Parameters:
mixed $element The element to remove from the list
bool $strict Whether to check the type of the element match
Returns:
bool

Definition at line 155 of file ElggPriorityList.php.

ElggPriorityList::rewind (  ) 

Iterator.

PHP Iterator Interface

See also:
Iterator::rewind()
Returns:
void

Definition at line 307 of file ElggPriorityList.php.

ElggPriorityList::sort ( callback = null  ) 

Sort the elements optionally by a callback function.

If no user function is provided the elements are sorted by priority registered.

The callback function should accept the array of elements as the first argument and should return a sorted array.

This function can be called multiple times.

Parameters:
callback $callback The callback for sorting. Numeric sorting is the default.
Returns:
bool

Definition at line 214 of file ElggPriorityList.php.

ElggPriorityList::valid (  ) 

PHP Iterator Interface.

See also:
Iterator::valid()
Returns:
bool

Definition at line 351 of file ElggPriorityList.php.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations
Generated on Thu Jun 20 00:01:25 2013 for Elgg by  doxygen 1.6.3