List

Home

A List is an object used to store ordered or unordered nodes that contain some form of data. Multiple Lists are efficient to combine with the linkLast() and linkFirst() functions which are used in the Urchin rendering process to sort Fragments based on distance with a bucket sort algorithm.

See also: ListNode

Constructors

List<T>( ): List<T> Standard constructor that initializes the list. All nodes are expected to have type: T. See also: ListNode

Variables

Public Variables

count: number The number of nodes in the list.
head: ListNode<T> The first node in the list.
minPriority: number The minimum priority value of some node in the list.
maxPriority: number The maximum priority value of some node in the list.
tail: ListNode<T> The last node in the list.

Functions

Public Functions

addByPriority(data: T | any, priority?: number): void Creates a ListNode with the given data and priority and adds it to the list based on the node's priority. Higher priority nodes (those with greater values) will be at the front of the list while lower priority nodes will be at the end. The default value for priority is 0.
addFirst(data: T | any, priority?: number): void Creates a ListNode with the given data and priority and adds it to the beginning of the list. The default value for priority is 0.
addLast(data: T | any, priority?: number): void Creates a ListNode with the given data and priority and adds it to the end of the list. The default value for priority is 0.
addListByPriority(list: List<T>): void Adds all of the nodes from the given list to the current list based on priority.
copy(): List<T> Returns a copy of the list. Any data in the ListNodes will be a copy of the original data when possible.
linkFirst(list List<T>): void Links the given list to the beginning of the current list and updates the count, minPriority and maxPriority values.
linkLast(list List<T>): void Links the given list to the end of the current list and updates the count, minPriority, and maxPriority values.

Private Functions

updatePriority(priority: number): void A private function used by the list to updated the minPriority and maxPriority values when a new addition is made to the list.

Home

Copyright © 2020 Trevor Richard