Elgg  Version 1.9
Public Member Functions | List of all members
ElggPriorityList Class Reference
Inheritance diagram for ElggPriorityList:

Public Member Functions

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

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$elementsAn 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$elementThe element to add to the list.
mixed$priorityPriority 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$exactunused
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$elementThe element to check.
bool$strictUse 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$priorityThe 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$nearMake 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$elementThe element to check for.
bool$strictUse 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$elementThe element to move
int$new_priorityThe new priority for the element
bool$strictWhether 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$elementThe element to remove from the list
bool$strictWhether 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$callbackThe 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: