WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\collections

class LinkedList

Class Methods Summary

public function &get(unkown_type$index)Returns the element at the specified index.public function &getFirst()Returns the first element that was added to the list.public function &getLast()Returns the last element that was added to the list.public function &remove(int$index)Removes an element given its index.public function &removeElement(mixed$val)Removes a specific element from the list.public function &removeFirst()Removes the first element in the list.public function &removeLast()Removes the last element in the list.public function __construct(int$max)Creates new instance of the class.public function add(mixed$el)Adds new element to the list.public function clear()Removes all of the elements from the list.public function contains(mixed$el)Checks if a given element is in the list or not.public function countElement(mixed$el)Returns the number of times a given element has appeared on the list.public function current()Returns the element that the iterator is currently is pointing to.public function indexOf(mixed$el)Returns the index of an element.public function insert(mixed$el, int$position)Insert new element in the middle of the list.public function insertionSort(boolean$ascending)Sort the elements of the list using insertion sort algorithm.public function key()Returns the current node in the iterator.public function max()Returns the number of maximum elements the list can hold.public function next()Returns the next element in the iterator.public function replace(mixed$oldEl, mixed$newEl)Replace an element with new one.public function rewind()Return iterator pointer to the first element in the list.public function size()Returns the number of elements in the list.public function toArray()Returns an array that contains the elements of the list.public function valid()Checks if the iterator has more elements or not.

Class Methods Details

public function &get(unkown_type$index)Returns the element at the specified index.

Parameters:

  • unkown_type $index
Returns: mixedThe element at the specified index. If the list is empty or the given index is out of list bounds, The method will return null.
public function &getFirst()Returns the first element that was added to the list. Returns: mixedThe first element that was added to the list. If the list is empty, The method will return null.public function &getLast()Returns the last element that was added to the list. Returns: mixedThe last element that was added to the list. If the list is empty, The method will return null.public function &remove(int$index)Removes an element given its index. If the given index is in the range [0, LinkedList::size() - 1] the element at the given index is returned. If the list is empty or the given index is out of the range, the method will return null. Also the method will return null if the given index is not an integer.

Parameters:

  • int $index The index of the element.
Returns: mixedThe element that was removed. null if no element is removed.
public function &removeElement(mixed$val)Removes a specific element from the list. The method will remove the first occurrence of the element if it is repeated. Note that the method use strict comparison to check for equality.

Parameters:

  • mixed $val The element that will be removed.
Returns: mixedThe method will return The element after removal if the given element is removed. Other than that, the method will return null.
public function &removeFirst()Removes the first element in the list. Returns: mixedIf the list has elements, the first element is returned. If the list is empty, the method will return null.public function &removeLast()Removes the last element in the list. Returns: mixedIf the list has elements, the last element is returned. If the list is empty, the method will return null.public function __construct(int$max)Creates new instance of the class.

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.
public function add(mixed$el)Adds new element to the list.

Parameters:

  • mixed $el The element that will be added. It can be of any type.
Returns: booleantrue if the element is added. The method will return false only if the list accepts a limited number of elements and that number has been reached.
public function clear()Removes all of the elements from the list. public function contains(mixed$el)Checks if a given element is in the list or not. Note that the method uses strict equality operator '===' to check for element existence.

Parameters:

  • mixed $el The element that will be checked.
Returns: booleantrue if the element is on the list. Other than that, the method will return false.
public function countElement(mixed$el)Returns the number of times a given element has appeared on the list.

Parameters:

  • mixed $el The element that will be counted.
Returns: intThe number of times the element has appeared on the list. If the element does not exist, 0 is returned.
public function current()Returns the element that the iterator is currently is pointing to. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: mixedThe element that the iterator is currently is pointing to.public function indexOf(mixed$el)Returns the index of an element. Note that the method is using strict comparison operator to search (===). The method will return the index of the first match it found if the list contain the same element more than once.

Parameters:

  • mixed $el The element to search for.
Returns: intThe index of the element if found. If the list does not contain the element or is empty, the method will return -1.
public function insert(mixed$el, int$position)
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.
Note that the element at the specified index will be moved to the next position and the new element will replace it.

Parameters:

  • mixed $el The new element that will be inserted.
  • int $position The index at which the element will be inserted in.
Returns: booleanIf the element is inserted, the method will return true. If not, the method will return false.
public function insertionSort(boolean$ascending)
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.
Returns: booleanThe method will return true if list elements have been sorted. The only cases that the method will return false is when the list has an object which does not implement the interface Comparable or it has a mix of objects and primitive types. Also, the method will return false if not all elements of the same primitive type.
public function key()Returns the current node in the iterator. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: Node|nullAn object of type 'Node' or null if the list is empty or the iterator is finished.public function max()Returns the number of maximum elements the list can hold. Returns: intIf the maximum number of elements was set to 0 or a negative number, the method will return -1 which indicates that the list can have any number of elements. Other than that, the method will return the maximum number of elements.public function next()Returns the next element in the iterator. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: mixed|nullThe next element in the iterator. If the iterator is finished or the list is empty, the method will return null.public function replace(mixed$oldEl, mixed$newEl)Replace an element with new one.

Parameters:

  • mixed $oldEl The element that will be replaced.
  • mixed $newEl The element that will replace the old one.
Returns: booleanThe method will return true if replaced. if the element is not replaced, the method will return false.
public function rewind()Return iterator pointer to the first element in the list. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.public function size()Returns the number of elements in the list. Returns: intThe number of elements in the list.public function toArray()Returns an array that contains the elements of the list. Returns: arrayAn array that contains the elements of the list.public function valid()Checks if the iterator has more elements or not. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: booleanIf there is a next element, the method will return true. False otherwise.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024