Skip to content

PachiSystems/JSLinkedList

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSLinkedList

Implementation of LinkedList in JavaScript. Eventually will emulate JavaSE 7's LinkedList type.

Current version: 1.0.0

Please make a feature request to be included in version 2 to enhance the LinkedList. Currently the module works as a Node module, RequireJS module and as a standalone module depending on how you want to use it.

Field Summary

  • modCount - Number of times the list has been structurally modified.

Constructor Summary

Constructor Description Version Introduced
LinkedList() Constructs an empty list 0.37.0
LinkedList(Collection) Constructs a list using the colelction passed in the order they are in the collection. 1.0.0

Method Summary

Checked items indicate working functionality. Unchecked items are not implemented as of yet. Methods taken from java.util.LinkedList implementation which can be found at http://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html

Return Method Name Method Description Version Introduced
bool add(Element) Adds the specified Element to the end of the list. 0.37.0
bool add(index, Element) Adds the specified Element at the specified position in the list. Does not replace the Element. 0.37.0
bool addAll(Collection) Appends all of the elmeents in the specified collection to the end of the list, in the order that they are returned by the specified collection's itterator. 1.0.0
bool addAll(index, Collection) Inserts all of the elments in the specified collection into the list, starting at the specified position. 1.0.0
bool addFirst(Element) Inserts the specified Element at the beginning of the list. 0.37.0
bool addLast(Element) Appends the specified Element to the end of the list. 0.37.0
void clear() Removes all of the Elements from the list. 0.37.0
Object clone() Returns a shallow copy of the list. 0.37.0
bool contains(Object) Returns true if the list contains the specified object. 0.37.0
Element Element() Returns, but does not remove, the head (first Element) of this list. 0.37.0
Element get(index) Returns the Element at the specified index. 0.37.0
Element getFirst() Returns the first Element in the list. 0.37.0
Element getLast() Returns the last Element in the list. 0.37.0
int indexOf(Object) Returns the index of the first occurrence of the specified object in the list, or -1 if the list doesn't contain the object. 0.37.0
int lastIndexOf(Object) Returns the index of the last occurance of the specified object in the list, or -1 if this list does not contain the object. 0.37.0
bool offer(Element) Adds the specified Element as the tail (last Element) of the list. 0.37.0
bool offerFirst(Element) Adds the specified Element at the front of the list. 0.37.0
bool offerLast(Element) Adds the specified Elements at the end of the list. 0.37.0
Element peek() Retrieves, but does not remove, the head (first Element) of the list. 0.37.0
Element peekFirst() Retrieves, but does not remove, the first Element of the list, or returns null if the list is empty. 0.37.0
Element peekLast() Retrieves, but does not remove, the last Element of the list, or returns null if the list is empty. 0.37.0
Element poll() Retrieves and removes the head (first Element) of the list. 0.37.0
Element pollFirst() Retrieves and removes the first Element of the list, or returns null if the list is empty. 0.37.0
Element pollLast() Retrieves and removes the last Element of the list, or returns null if the list is empty. 0.37.0
Element pop() Pops an Element from the stack represented by this list. 0.37.0
bool push(Element) Pushes an Element onto the stack represented by the list. 0.37.0
Element remove() Retrieves and removes the head (first Element) of the list. 0.37.0
Element remove(index) Retrieves and removes the Element at the specified index. 0.37.0
Element removeFirst() Retrieves and removes the first Element from the list. 0.37.0
bool removeFirstOccurrence(Object) Removes the first occurance of the specified object in the list (when traversing from head to tail). 0.37.0
Element removeLast() Removes and returns the last Element in the list. 0.37.0
bool removeLastOccurrence(Object) Removes the last occurance of the specified object in the list (when traversing from head to tail). 0.37.0
Element set(index, Element) Replaces the Element at the specified position in the list with the specified Element. Returns the Element previously at the specified position. 0.37.0
int size() Returns the number of Elements in the list. 0.37.0
Object toArray() Returns an array containing all of the Elements in the list in proper sequence (from head to tail). 0.37.0
string toString() Returns a string representation of the list. The string representation consists of a list of the list's Elements in order from head to tail, enclosed in square brackets ("[]"). Adjacent Elements are separated by the characters ", " (comma and space). Note: Does not expand objects/arrays. 0.37.0

Enhancements

Return Method Name Method Description Version Included
bool insertAfter(index,Element) Adds the specified Element to the list one position after the specified index. 0.37.0
bool insertBefore(index,Element) Adds the specified Element to the list one position before the specified index. 0.37.0
void sort(Function) Sorts the list based on the function passed in the same manner as JavaScript's Array.prototype.sort. 0.37.0
void sortedAdd(Element,Function) Adds an Element into the list in a sorted position based upon the function passed in the same manner as JavaScript's Array.prototype.sort. 0.38.0

About

Implementation of LinkedList in JavaScript. Eventually will emulate Java's LinkedList type.

Resources

License

Stars

Watchers

Forks

Packages

No packages published