Difference between revisions of "LL Nth"
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Linked list library functions]] | ||
+ | |||
== LL_Nth(LL, n) == | == LL_Nth(LL, n) == | ||
Returns the «n»th item in the linked list «LL», or returns [[Null]] when «LL» has fewer than «n» items. | Returns the «n»th item in the linked list «LL», or returns [[Null]] when «LL» has fewer than «n» items. | ||
− | This is a slow operation, which requires «n» steps to | + | This is a slow operation, which requires «n» steps to complete, since it must walk the linked list. Once you have finished collecting items, it is better to convert the linked list to an array using [[LL_To_RArray]] or [[LL_To_Array]] before using the collection. Once you've converted to an array, then random access into the array can be done in constant time using [[Slice]] or [[Subscript]]. |
To use this function, you must add the [[Linked list library]] to your model. | To use this function, you must add the [[Linked list library]] to your model. | ||
+ | |||
+ | ==Library== | ||
+ | [[Linked list library]] ([[media:Linked List Library.ana|Linked List Library.ana]]) | ||
+ | :Use [[File menu|File]] → '''Add Library...''' to add this library | ||
== See Also == | == See Also == | ||
* [[Linked list library]] | * [[Linked list library]] | ||
+ | * [[media:Linked List Library.ana|Linked List Library.ana]] | ||
* [[LL_First]] | * [[LL_First]] |
Latest revision as of 19:50, 24 May 2016
LL_Nth(LL, n)
Returns the «n»th item in the linked list «LL», or returns Null when «LL» has fewer than «n» items.
This is a slow operation, which requires «n» steps to complete, since it must walk the linked list. Once you have finished collecting items, it is better to convert the linked list to an array using LL_To_RArray or LL_To_Array before using the collection. Once you've converted to an array, then random access into the array can be done in constant time using Slice or Subscript.
To use this function, you must add the Linked list library to your model.
Library
Linked list library (Linked List Library.ana)
- Use File → Add Library... to add this library
See Also
Comments
Enable comment auto-refresher