new Queue()
js_cols.Queue provides the implementation of a Queue based on a doubly Linked List. The list is circular, keeping a dummy element ("sentinel") .
- See:
-
Extends
Methods
-
add(index, element)
-
Adds an element at index i in the list
Parameters:
Name Type Description index
Integer the index of the element
element
* the element to add
- Inherited From:
-
addFirst(element)
-
Adds an element to the beginning of the list
Parameters:
Name Type Description element
* the element to add
- Inherited From:
-
addLast(element)
-
Adds an element to the end of the list
Parameters:
Name Type Description element
* the element to add
- Inherited From:
-
clear()
-
Removes all elements from the list.
- Inherited From:
-
clone() → {js_cols.LinkedList}
-
Creates a new list and inserts all elements from this list to the new list and returns it
- Inherited From:
Returns:
a shallow clone of this list
- Type
- js_cols.LinkedList
-
contains(o)
-
Checks whether a given element is contained in the list
Parameters:
Name Type Description o
* the element to locate
- Inherited From:
-
containsAll(col) → {Boolean}
-
Checks that all values contained in the collection are also contained in the LinkedList WARNING: this runs in O(n*m) where n is the cardinality of the LinkedList and m is the cardinality of the collection
Parameters:
Name Type Description col
- Inherited From:
Returns:
- Type
- Boolean
-
dequeue() → {*}
-
Retrieves and removes the head of this queue.
Returns:
The element at the head of this queue. Returns undefined if the queue is empty.
- Type
- *
-
enqueue(element)
-
Puts the specified element on this queue.
Parameters:
Name Type Description element
* The element to be added to the queue.
-
every(f, opt_obj) → {boolean}
-
Calls a function on each item in the LinkedList and returns true only if every function call returns a true-like value.
Parameters:
Name Type Argument Description f
function The function to call for each item. The function takes three arguments: the value, the key, and the LinkedList, and returns a boolean.
opt_obj
Object <optional>
The object context to use as "this" for the function.
- Inherited From:
Returns:
Whether f evaluates to true for every element in the LinkedList.
- Type
- boolean
-
filter(f, opt_obj) → {Array}
-
Calls a function on each item in the LinkedList, if the function returns true, the key/value pair is inserted into an object that is returned when all elements in the the list has been visited
Parameters:
Name Type Argument Description f
function The function to call for each item. The function takes three arguments: the value, the key, and the LinkedList.
opt_obj
Object <optional>
The object context to use as "this" for the function.
- Inherited From:
Returns:
The elements that evaluated to true in the function calls for each element in the LinkedList.
- Type
- Array
-
forEach(f, opt_obj)
-
Calls a function on each item in the LinkedList.
Parameters:
Name Type Argument Description f
function The function to call for each item. The function takes three arguments: the value, the key, and the LinkedHashMap.
opt_obj
Object <optional>
The object context to use as "this" for the function.
- Inherited From:
-
getCount() → {Integer}
-
Returns the number of elements in the list
- Inherited From:
Returns:
number of elements in the list
- Type
- Integer
-
getFirst() → {*}
-
Returns the first element in the list
- Inherited From:
Returns:
the first element of the list
- Type
- *
-
getLast() → {*}
-
Returns the last element in the list
- Inherited From:
Returns:
the last element of the list
- Type
- *
-
getValues() → {Array}
-
Returns the values of the list in an Array. This operation is equal to toArray
- Inherited From:
Returns:
The values in the list.
- Type
- Array
-
insert(element)
-
Inserts an element to the head of the list this operation is equal to addFirst
Parameters:
Name Type Description element
* the element to insert
- Inherited From:
-
insertAll(col)
-
Inserts all values from the collection into the list
Parameters:
Name Type Description col
- Inherited From:
-
isEmpty() → {Boolean}
-
Returns true if the size of the list is zero.
- Inherited From:
Returns:
- Type
- Boolean
-
iterator(startpos) → {js_cols.LinkedList.LinkedListIterator}
-
Returns an iterator over the list, starting at the specified position
Parameters:
Name Type Description startpos
Integer the start position of this Iterator
- Inherited From:
Returns:
an iterator over the elements in the list
-
map(f, opt_obj) → {Array}
-
Calls a function on each item in the LinkedList and returns the results of those calls in an array.
Parameters:
Name Type Argument Description f
function The function to call for each item. The function takes three arguments: the value, the key, and the LinkedList.
opt_obj
Object <optional>
The object context to use as "this" for the function.
- Inherited From:
Returns:
The results of the function calls for each element in the LinkedList.
- Type
- Array
-
peek() → {*}
-
Retrieves but does not remove the head of this queue.
Returns:
The element at the head of this queue. Returns null if the queue is empty.
- Type
- *
-
remove(o) → {Boolean}
-
Removes a given element from the queue, if it is contained
Parameters:
Name Type Description o
* the element to remove
Returns:
wheter the object was removed;
- Type
- Boolean
-
removeAll(col)
-
Removes a all values contained in the collection from the list. WARNING: this runs in O(n*m) where n is the cardinality of the LinkedList and m is the cardinality of the collection
Parameters:
Name Type Description col
- Inherited From:
-
removeFirst() → {*}
-
Removes and returns the first element in the list
- Inherited From:
Returns:
the first element of the list
- Type
- *
-
removeIndex(index)
-
Removes the element at index i from the list
Parameters:
Name Type Description index
Integer the index of the element to remove
- Inherited From:
-
removeLast() → {*}
-
Removes and returns the last element in the list
- Inherited From:
Returns:
the last element of the list
- Type
- *
-
removeObject(o) → {Boolean}
-
Removes a given element from the list, if it is contained
Parameters:
Name Type Description o
* the element to remove
- Inherited From:
Returns:
wheter the object was removed;
- Type
- Boolean
-
some(f, opt_obj) → {boolean}
-
Calls a function on each item in the LinkedList and returns true if any of those function calls returns a true-like value.
Parameters:
Name Type Argument Description f
function The function to call for each item. The function takes three arguments: the value, the key, and the LinkedList, and returns a boolean.
opt_obj
Object <optional>
The object context to use as "this" for the function.
- Inherited From:
Returns:
Whether f evaluates to true for at least one element in the LinkedList.
- Type
- boolean
-
toArray() → {Array}
-
Returns an Array with the values of the list.
- Inherited From:
Returns:
The values in the list.
- Type
- Array