Class fullproof.ResultSet
Defined in: fullproof-all-large.js.
Constructor Attributes | Constructor Name and Description |
---|---|
fullproof.ResultSet(comparatorObject, data)
Provides an object containing a sorted array, and providing elementary
set operations: merge (union), intersect, and substract (complement).
|
Method Attributes | Method Name and Description |
---|---|
clone()
Creates a clone of this result set.
|
|
forEach(callback)
Iterates over all the element of the array, and calls the provided function with each values.
|
|
Returns the sorted javascript array managed by this ResultSet.
|
|
getItem(i)
Returns the value stored at a given offset
|
|
getSize()
Return the size of the managed array.
|
|
insert()
Insert values into the array of data managed by this ResultSet.
|
|
intersect(set)
Intersect operation.
|
|
merge(set, mergeFn)
Union operation.
|
|
setComparatorObject(comparatorObject)
Changes the comparatorObject associated to this set, and sorts the data.
|
|
setDataUnsafe(sorted_array)
Sets the sorted array managed by this ResultSet.
|
|
substract(set)
Substraction operation.
|
|
toString()
Returns a string representation of this object's data.
|
Class Detail
fullproof.ResultSet(comparatorObject, data)
Provides an object containing a sorted array, and providing elementary
set operations: merge (union), intersect, and substract (complement).
It maintains internally a sorted array of data. The optional comparator
must be an object of the form {lower_than: func_lt, equals: func_equal}
- Parameters:
- comparatorObject
- a comparator object that provides two functions: lower_than and equals. If not defined, a default comparator using the javascript < operator is used. If you're only storing integer values, you can safely omit this argument.
- data
Method Detail
clone()
Creates a clone of this result set. The managed array is cloned too, but not
the values it contains.
- Returns:
- a copy of this ResultSet.
forEach(callback)
Iterates over all the element of the array, and calls the provided function with each values.
- Parameters:
- callback
- the function called with each element of the array
- Returns:
- this ResultSet instance
getDataUnsafe()
Returns the sorted javascript array managed by this ResultSet.
getItem(i)
Returns the value stored at a given offset
- Parameters:
- i
- the offset of the value
- Returns:
- a value stored by the resultset
getSize()
Return the size of the managed array.
insert()
Insert values into the array of data managed by this ResultSet. The insertion is optimized
when the inserted values are greater than the last inserted values (the value is just pushed
to the end of the array). Otherwise, a binary search is done in the array to find the correct
offset where to insert the value. When possible, always insert sorted data.
- Parameters:
- values...
- any number of values to insert in this resultset.
intersect(set)
Intersect operation. Modify the current ResultSet so that is only contain values that are also contained by another ResultSet or array.
- Parameters:
- set
- another ResultSet, or an array of sorted values
- Returns:
- this ResultSet, possibly modified by the intersect operation
merge(set, mergeFn)
Union operation. Merge another ResultSet or a sorted javascript array into this ResultSet.
If the same value exists in both sets, it is not injected in the current set, to avoid duplicate values.
- Parameters:
- set
- another ResultSet, or an array of sorted values
- mergeFn
- Returns:
- this ResultSet, possibly modified by the merge operation
setComparatorObject(comparatorObject)
Changes the comparatorObject associated to this set, and sorts the data.
Use this function if you want to sort the data differently at some point.
- Parameters:
- comparatorObject
- the comparator to use
- Returns:
- this ResultSet instance
setDataUnsafe(sorted_array)
Sets the sorted array managed by this ResultSet.
- Parameters:
- sorted_array
- a sorted array
- Returns:
- this ResultSet instance
substract(set)
Substraction operation. Modify the current ResultSet so that any value contained in the provided set of values are removed.
- Parameters:
- set
- another ResultSet, or an array of sorted values
- Returns:
- this ResultSet, possibly modified by the substract operation
toString()
Returns a string representation of this object's data.
- Returns:
- a string