Algorithms and data structures for JS/TS
  • Introduction
  • GETTING STARTED
    • TS
    • Node.js
    • ES Modules
    • Browsers
  • PUBLIC API
    • How to read
    • Linked lists
      • SinglyLinkedList
      • DoublyLinkedList
      • CircularlyLinkedList
    • Stacks and queues
      • LinkedStack
      • LinkedQueue
      • LinkedDeque
      • CircularQueue
      • CircularArrayBuffer
      • UnsortedPriorityQueue
      • SortedPriorityQueue
      • AdaptableHeapPriorityQueue
    • Maps
      • SortedMap
      • MaximaSet
      • AVLTreeMap
      • SplayTreeMap
      • RedBlackTreeMap
    • Trees
      • GeneralTree
      • LinkedBinaryTree
      • PreorderTreeTraversal
      • InorderTreeTraversal
      • PostorderTreeTraversal
      • EulerTourTreeTraversal
    • Searches
      • Binary search
      • Quick select
    • Text processing
      • Longest common subsequence
      • Boyer-Moore
      • Knuth-Morris-Pratt
    • Position
    • Locator
    • Comparators
  • CONTRIBUTION NOTES
    • How to contribute
    • Project structure
  • Changelog
Powered by GitBook
On this page
  • element
  • index

Was this helpful?

  1. PUBLIC API

Locator

Represents the placement of a single element in array data structure.

PreviousPositionNextComparators

Last updated 5 years ago

Was this helpful?

Unlike , the Locator class instance is stored directly in the data structure (which is array in this case) and used to propagate changes of the element's placement in result of operations. Without it you would lost the index of particular element in the array as soon as it been tossed somehow and had to look up for it again in O(n) instead of constant time access with locator.

element

element: T

Element represented by this locator. This field is read only.

Generic types (only for TS):

T - Type of elements stored in the data structure this locator belongs to.

index

index: number

Index of the element in its containing array. This field is read only.

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.

Position