Position
Represents the location of a single element in linked data structure.
Position represents a location of a single element in linked data structure. It allows access to list element in O(1) time instead of O(n) when searching through entire list by value.
Client code is not allowed to create an instance of Position class directly but can often obtain it from methods called on linked-based structures. This class brings difference between working with inner realization of a data structure and getting access only to data viable for developer. So one purpose of it is to be an adapter for safety.
Another objective of position is to point directly on certain node of the structure to grant access to it in constant time.
element
Element at this position. This field is read only.
Generic types (only for TS):
T - Type of elements stored in the data structure this position points on.
Examples:
Do not use _internal
property from your code. It stays public
because is used by external code in the package realization. But TS does not yet have package
scope limitation level so this seems to be the only option.
Last updated
Was this helpful?