company logo

Property :: plus - Union two collections

The result collection contains the instances that exist in the first or in the second operand collections. The bDistinct option determines, whether the result may contain duplicates or not. The existence of an instance in a collection can be checked based on a access key (passing true for bSortKey) or on local identities (LOID). Using the LOID is save but comparing the key is much faster. Hence, the key check should be used whenever possible.

The function throws an exception, when operands passed are invalid or when keys are not comparable (bSortKey=true).

Notes:

The function has been named plus, since union is a reserved keyword.

Return value:  Result property handle ( odaba::Property & )

Reference to the property handle that contains the result of an operation. Note that invalid properties may cause exceptions.

Implementation overview

Implementation details

  1. Create union result in calling property handle
    odaba::Property & Property  :: plus ( odaba::Property &cProperty, bool bSortKey )

    The function creates the union collection from the collection referenced by the calling property handle and and the collection passed in rProperty, and stores the result in the collection of the calling property handle.

    The function creates the plus (union) result in the current property, i.e. all instances from the collection referenced in rProperty are inserted into the current collection. When all access keys accept duplicates, the result may contain duplicate instances.

    • cProperty - Property reference

      A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

    • bSortKey - Sort key option

      The sort key option indicates whether the operation should be performed according to the sort key set for the collections (true). Otherwise (false) the operation is performed by comparing instances.

  2. to list
  3. Create union result in calling property handle without duplicates
    odaba::Property & Property  :: plus ( odaba::Property &cProperty, bool bSortKey, bool bDistinct )

    The function creates the union collection from the collection referenced by the calling property handle and and the collection passed in rProperty, and stores the result in the collection of the calling property handle.

    The function creates the plus (union) result in the current property, i.e. all instances from the collection referenced in rProperty are inserted into the current collection. No duplicates are inserted.

    • cProperty - Property reference

      A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

    • bSortKey - Sort key option

      The sort key option indicates whether the operation should be performed according to the sort key set for the collections (true). Otherwise (false) the operation is performed by comparing instances.

    • bDistinct - Distinct option

      Passing a distinct option true forces the function to remove (or not to store) duplicates from the result collection.

  4. to list
  5. Create union result
    odaba::Property & Property  :: plus ( odaba::Property &cProperty1, odaba::Property &cProperty2, bool bSortKey )

    The plus (union) operation is performed with the operand property handles (collections) passed in rProperty1 and rProperty2. The result is stored in the collection handled by the current (calling) property handle. When all access keys in the target collection accept duplicates, the result may contain duplicate instances.

    When the current property handle refers to a non empty collection, all instances are removed before performing the operation. When the calling property handle is not opened (invalid), the function creates a temporary extend for storing the result.

    • cProperty1 - Property reference

      A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

    • cProperty2 - Property reference

      A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

    • bSortKey - Sort key option

      The sort key option indicates whether the operation should be performed according to the sort key set for the collections (true). Otherwise (false) the operation is performed by comparing instances.

  6. to list
  7. Create union result without duplicates
    odaba::Property & Property  :: plus ( odaba::Property &cProperty1, odaba::Property &cProperty2, bool bSortKey, bool bDistinct )

    The plus (union) operation is performed with the operand property handles (collections) passed in rProperty1 and rProperty2. The result is stored in the collection handled by the current (calling) property handle. No duplicates are inserted.

    When the current property handle refers to a non empty collection, all instances are removed before performing the operation. When the calling property handle is not opened (invalid), the function creates a temporary extend for storing the result.

    • cProperty1 - Property reference

      A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

    • cProperty2 - Property reference

      A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

    • bSortKey - Sort key option

      The sort key option indicates whether the operation should be performed according to the sort key set for the collections (true). Otherwise (false) the operation is performed by comparing instances.

    • bDistinct - Distinct option

      Passing a distinct option true forces the function to remove (or not to store) duplicates from the result collection.

  8. to list