API Docs for: 0.1.21
Show:

Queue Class

The Queue class provides the main functionality of a queue implemented using a doubly linked list.

Methods

add

(
  • index
  • value
)

Insert a new value at the specified index

Parameters:

  • index Object

    The index where the new value is to be inserted.

  • value Object

    The new value for the index.

Returns:

void

bottom

()

Peeks at the node from the beginning of the doubly linked list

Returns:

any The value of the first node.

count

()

Counts the number of elements in the doubly linked list

Returns:

number the number of elements in the doubly linked list.

current

()

Return current list entry

Returns:

any The current node value.

dequeue

()

Dequeues a node from the queue

Returns:

any The value of the dequeued node.

enqueue

(
  • value
)

Adds an element to the queue

Parameters:

  • value Object

    The value to enqueue.

Returns:

void

isEmpty

()

Checks whether the doubly linked list is empty

Returns:

boolean whether the doubly linked list is empty.

key

()

Return current node index

Returns:

any The current node index.

next

()

Move to next entry

Returns:

void

pop

()

Pops a node from the end of the doubly linked list

Returns:

any The value of the popped node.

prev

()

Move to previous entry

Returns:

void

push

(
  • value
)

Pushes an element at the end of the doubly linked list

Parameters:

  • value Object

    The value to push.

Returns:

void

rewind

()

Rewind iterator back to the start

Returns:

void

shift

()

Shifts a node from the beginning of the doubly linked list

Returns:

any The value of the shifted node.

toArray

()

Export the list to array

Returns:

Array The exported array

top

()

Peeks at the node from the end of the doubly linked list

Returns:

any The value of the last node.

toString

()

Serializes the list to string

Returns:

string The serialized string.

unshift

(
  • value
)

Prepends the doubly linked list with an element

Parameters:

  • value Object

    The value to unshift.

Returns:

void

valid

()

Check whether the doubly linked list contains more nodes

Returns:

boolean true if the doubly linked list contains any more nodes, false otherwise.

Properties

_current

DoublyLinkedListNode private

Reference to iterated element in list

_head

DoublyLinkedListNode private

Reference to head(first) element in list

_key

Number private

Iteration pointer

_length

Number private

Count of elements in list

_tail

DoublyLinkedListNode private

Reference to tail(last) element in list