src/basis/data/dataset/Subtract.js
function(minuend, subtrahend){
    var delta;
    var operandsChanged = false;
    var oldMinuend = this.minuend;
    var oldSubtrahend = this.subtrahend;

    minuend = resolveDataset(this, this.setMinuend, minuend, 'minuendRA_');
    subtrahend = resolveDataset(this, this.setSubtrahend, subtrahend, 'subtrahendRA_');

    // set new minuend if changed
    if (oldMinuend !== minuend)
    {
      operandsChanged = true;
      this.minuend = minuend;

      var listenHandler = this.listen.minuend;
      if (listenHandler)
      {
        if (oldMinuend)
          oldMinuend.removeHandler(listenHandler, this);

        if (minuend)
          minuend.addHandler(listenHandler, this);
      }

      this.emit_minuendChanged(oldMinuend);
    }

    // set new subtrahend if changed
    if (oldSubtrahend !== subtrahend)
    {
      operandsChanged = true;
      this.subtrahend = subtrahend;

      var listenHandler = this.listen.subtrahend;
      if (listenHandler)
      {
        if (oldSubtrahend)
          oldSubtrahend.removeHandler(listenHandler, this);

        if (subtrahend)
          subtrahend.addHandler(listenHandler, this);
      }

      this.emit_subtrahendChanged(oldSubtrahend);
    }

    if (!operandsChanged)
      return false;

    /** @cut */ basis.dev.setInfo(this, 'sourceInfo', {
    /** @cut */   type: 'Subtract',
    /** @cut */   source: [minuend, subtrahend]
    /** @cut */ });

    // apply changes
    if (!minuend || !subtrahend)
    {
      if (this.itemCount)
        this.emit_itemsChanged(delta = {
          deleted: this.getItems()
        });
    }
    else
    {
      var deleted = [];
      var inserted = [];

      for (var key in this.items_)
        if (!minuend.items_[key] || subtrahend.items_[key])
          deleted.push(this.items_[key]);

      for (var key in minuend.items_)
        if (!this.items_[key] && !subtrahend.items_[key])
          inserted.push(minuend.items_[key]);

      if (delta = getDelta(inserted, deleted))
        this.emit_itemsChanged(delta);
    }

    return delta;
  }
function(minuend, subtrahend){
    var delta;
    var operandsChanged = false;
    var oldMinuend = this.minuend;
    var oldSubtrahend = this.subtrahend;

    minuend = resolveDataset(this, this.setMinuend, minuend, 'minuendRA_');
    subtrahend = resolveDataset(this, this.setSubtrahend, subtrahend, 'subtrahendRA_');

    // set new minuend if changed
    if (oldMinuend !== minuend)
    {
      operandsChanged = true;
      this.minuend = minuend;

      var listenHandler = this.listen.minuend;
      if (listenHandler)
      {
        if (oldMinuend)
          oldMinuend.removeHandler(listenHandler, this);

        if (minuend)
          minuend.addHandler(listenHandler, this);
      }

      this.emit_minuendChanged(oldMinuend);
    }

    // set new subtrahend if changed
    if (oldSubtrahend !== subtrahend)
    {
      operandsChanged = true;
      this.subtrahend = subtrahend;

      var listenHandler = this.listen.subtrahend;
      if (listenHandler)
      {
        if (oldSubtrahend)
          oldSubtrahend.removeHandler(listenHandler, this);

        if (subtrahend)
          subtrahend.addHandler(listenHandler, this);
      }

      this.emit_subtrahendChanged(oldSubtrahend);
    }

    if (!operandsChanged)
      return false;

    /** @cut */ basis.dev.setInfo(this, 'sourceInfo', {
    /** @cut */   type: 'Subtract',
    /** @cut */   source: [minuend, subtrahend]
    /** @cut */ });

    // apply changes
    if (!minuend || !subtrahend)
    {
      if (this.itemCount)
        this.emit_itemsChanged(delta = {
          deleted: this.getItems()
        });
    }
    else
    {
      var deleted = [];
      var inserted = [];

      for (var key in this.items_)
        if (!minuend.items_[key] || subtrahend.items_[key])
          deleted.push(this.items_[key]);

      for (var key in minuend.items_)
        if (!this.items_[key] && !subtrahend.items_[key])
          inserted.push(minuend.items_[key]);

      if (delta = getDelta(inserted, deleted))
        this.emit_itemsChanged(delta);
    }

    return delta;
  }
function ( minuend , subtrahend ) { var delta ; var operandsChanged = false ; var oldMinuend = this . minuend ; var oldSubtrahend = this . subtrahend ; minuend = resolveDataset ( this , this . setMinuend , minuend , 'minuendRA_' ) ; subtrahend = resolveDataset ( this , this . setSubtrahend , subtrahend , 'subtrahendRA_' ) ; // set new minuend if changed if ( oldMinuend !== minuend ) { operandsChanged = true ; this . minuend = minuend ; var listenHandler = this . listen . minuend ; if ( listenHandler ) { if ( oldMinuend ) oldMinuend . removeHandler ( listenHandler , this ) ; if ( minuend ) minuend . addHandler ( listenHandler , this ) ; } this . emit_minuendChanged ( oldMinuend ) ; } // set new subtrahend if changed if ( oldSubtrahend !== subtrahend ) { operandsChanged = true ; this . subtrahend = subtrahend ; var listenHandler = this . listen . subtrahend ; if ( listenHandler ) { if ( oldSubtrahend ) oldSubtrahend . removeHandler ( listenHandler , this ) ; if ( subtrahend ) subtrahend . addHandler ( listenHandler , this ) ; } this . emit_subtrahendChanged ( oldSubtrahend ) ; } if ( ! operandsChanged ) return false ; /** @cut */ basis . dev . setInfo ( this , 'sourceInfo' , { /** @cut */ type : 'Subtract' , /** @cut */ source : [ minuend , subtrahend ] /** @cut */ } ) ; // apply changes if ( ! minuend || ! subtrahend ) { if ( this . itemCount ) this . emit_itemsChanged ( delta = { deleted : this . getItems ( ) } ) ; } else { var deleted = [ ] ; var inserted = [ ] ; for ( var key in this . items_ ) if ( ! minuend . items_ [ key ] || subtrahend . items_ [ key ] ) deleted . push ( this . items_ [ key ] ) ; for ( var key in minuend . items_ ) if ( ! this . items_ [ key ] && ! subtrahend . items_ [ key ] ) inserted . push ( minuend . items_ [ key ] ) ; if ( delta = getDelta ( inserted , deleted ) ) this . emit_itemsChanged ( delta ) ; } return delta ; }
Set new minuend & subtrahend.
@param {basis.data.ReadOnlyDataset=} minuend
@param {basis.data.ReadOnlyDataset=} subtrahend
@return {object|boolean} Delta if changes happend
Set new minuend & subtrahend .