namespace \webfiori\collections
class LinkedList
Class Methods Summary
Class Methods Details
Parameters:
- unkown_type $index
Parameters:
- int $index The index of the element.
Parameters:
- mixed $val The element that will be removed.
Parameters:
- int $max The maximum number of elements that the list can hold. If 0 or a negative number is given, the list will be able to hold unlimited number of elements.
Parameters:
- mixed $el The element that will be added. It can be of any type.
Parameters:
- mixed $el The element that will be checked.
Parameters:
- mixed $el The element that will be counted.
Parameters:
- mixed $el The element to search for.
Insert new element in the middle of the list. The method will try to insert new element at the given position. If the position is index 0, the element will be inserted at the start of the list. If the position equals to the number of elements in the list, then the element will be inserted at the end of the list. If position is between 0 and LinkedList::size(), then the element will be inserted in the middle. The element will be not inserted in only two cases:
- Position is not between 0 and LinkedList::size() inclusive.
- The list accepts only a specific number of elements and its full.
Parameters:
- mixed $el The new element that will be inserted.
- int $position The index at which the element will be inserted in.
Sort the elements of the list using insertion sort algorithm. Note that sorting can be only applied to following types:
- numerical types
- strings
- Objects that implements the interface 'webfiori\collections\Comparable'
Parameters:
- boolean $ascending If set to true, list elements will be sorted in ascending order (From lower to higher). Else, they will be sorted in descending order (From higher to lower). Default is true.
Parameters:
- mixed $oldEl The element that will be replaced.
- mixed $newEl The element that will replace the old one.