Jetpack/Collections: Difference between revisions

Jump to navigation Jump to search
→‎Operators: add and, xor, and reference set theory
(→‎Operators: add and, xor, and reference set theory)
Line 169: Line 169:


== Operators ==
== Operators ==
add, subtract, and, xor (compare [http://en.wikipedia.org/wiki/Set_theory Set theory]) and sort


All operators observe the original collections they are constructed from, and adapt the result based on changes, and notify any observers that are registered on the operator result collection.
All operators observe the original collections they are constructed from, and adapt the result based on changes, and notify any observers that are registered on the operator result collection.
Line 174: Line 176:
   * Returns a collection that contains all values from coll1 and coll2.
   * Returns a collection that contains all values from coll1 and coll2.
   * If the same item is in both coll1 and coll2, it will be added only once.
   * If the same item is in both coll1 and coll2, it will be added only once.
  *
  * [http://en.wikipedia.org/wiki/Union_(set_theory) Union]
   *
   *
   * @param coll1 {Collection}
   * @param coll1 {Collection}
   * @param coll2 {Collection}
   * @param coll2 {Collection}
   * @returns {Collection}
   * @returns {Collection}
  *    Does not preserve order.
   function addColl(coll1, coll2)
   function addColl(coll1, coll2)
 
 
   * Returns a collection that contains all values from coll1 and coll2.
   * Returns a collection that contains all values from coll1 and coll2.
   * If the same item is in both coll1 and coll2, it will be added twice.
   * If the same item is in both coll1 and coll2, it will be added twice.
Line 186: Line 191:
   * @param coll2 {Collection}
   * @param coll2 {Collection}
   * @returns {Collection}
   * @returns {Collection}
  *    Preserves order
   function addCollWithDups(coll1, coll2)
   function addCollWithDups(coll1, coll2)
 
 
   * Returns a collection that contains all values from collBase,
   * Returns a collection that contains all values from collBase,
   * apart from those in collSubtract.
   * apart from those in collSubtract.
  *
  * [http://en.wikipedia.org/wiki/Set_difference Set difference]
   *
   *
   * @param collBase {Collection}
   * @param collBase {Collection}
   * @param collSubtract {Collection}
   * @param collSubtract {Collection}
   * @returns {Collection}
   * @returns {Collection}
  *    Preserves order of collBase.
   function subtractColl(collBase, collSubtract)
   function subtractColl(collBase, collSubtract)
    
 
  * Returns a collection that contains all values that are contained
  * in *both* coll1 and coll1.
  *
  * [http://en.wikipedia.org/wiki/Intersection_(set_theory) Intersection]
  *
  * @param coll1 {Collection}
  * @param coll2 {Collection}
  * @returns {Collection}
  *    Does not preserve order.
   function andColl(coll1, coll2)
 
  * Returns a collection that contains all values that are contained
  * only in coll1 or coll2, but *not in both*.
  *
  * [http://en.wikipedia.org/wiki/Symmetric_difference Symmetric difference]
  *
  * @param coll1 {Collection}
  * @param coll2 {Collection}
  * @returns {Collection}
  *    Does not preserve order.
  function xorColl(coll1, coll2)
 
   * Returns a new collection that is sorted based on the |sortFunc|.
   * Returns a new collection that is sorted based on the |sortFunc|.
   *
   *
Confirmed users
596

edits

Navigation menu