jsinq.List

As of version 1.0, JSINQ contains a complete implementation of System.Collections.Generic.List that you can use independently of the querying functionality. To use JSINQ's list implementation, all you have to do is include the file "jsinq.js". You can then use jsinq.List like you would System.Collections.Generic.List:

var list = new jsinq.List();
list.add("JSINQ");
list.insert(0, "Hello");
list.removeAt(1);
alert(list.item(0);
list.set(0, "Test");

You can also turn any jsinq.Enumerable into a list by invoking its "toList" method.

Methods

jsinq.List provides the following methods:

Method Static Description
add no Adds the specified item to the end of the list
item no Retrieves the element at the specified index
set no Sets the element at the specified index
addRange no Adds the elements of the specified collection to the end of the list
asReadOnly no Return a read-only list wrapper for the current collection
binarySearch no Searches a sorted list for the given element
clear no Empties the list
copyTo no Copies a range of elements from the list to the specified array
exists no Returns a boolean value indicating whether the list contains any elements satisfying the condition defined by the given predicate function
find no Returns the first occurrence of an element that satisfies the condition defined by the given predicate
findAll no Retrieves all the elements from the list that satisfy the condtion defined by the given predicate
findIndex no Returns the index of the first element in the list that satisfies the condition defined by the given predicate
findLast no Returns the last occurrence of an element that satisfies the condition defined by the given predicate
findLastIndex no Returns the index of the last element in the list that satisfies the condition defined by the given predicate
forEach no Performs the specified action for each element in the list
getEnumerator no Returns an enumerator that iterates through the list
getRange no Extracts a range of elements from the list. The operation performs a shallow copy of the extracted elements, i.e. reference types are not cloned.
indexOf no Returns the index of the first occurrence of the specified item in the list or a part thereof
insert no Inserts the specified element into the list at the specified position
insertRange no Inserts the elements in the specified collection into the list at the specified position
lastIndexOf no Returns the index of the last occurrence of the specified item in the list or a part thereof
remove no Removes the specified item from the list. Returns a boolean value indicating whether the operation was successful
removeAll no Removes all the elements from the list that satisfy the condition defined by the given predicate
removeAt no Removes the element at the given index from the list
removeRange no Removes a range of elements from the list
reverse no Reverses the order of the elements in the list
sort no Sorts the elements in the list or a portion thereof
toArray no Returns an array containing the elements in the list
toString no Returns a string representing the list
isReadOnly no Indicates whether this list is read-only
trueForAll no Returns true if all elements in the list satisfy the condition defined by the given predicate


Please check out the official .NET reference for additional information on how to use these methods: http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
Also look at the comments in the source code and of course the examples.

Last edited Mar 27, 2010 at 2:16 PM by kaijaeger, version 3

Comments

No comments yet.