function r = minus(p,q)
%CVDATA/MINUS  Implement P-Q, data difference.
%
% When a test metric exists in only P it will be copied 
% from that argument into the result. Metrics that only exist in Q not exist
% in the result.  When the same metric exists in both arguments the following 
% set difference rules apply:
% 
% DECISION Find the coverage points only exercised in data P.  The path counts
% are set to 0 if the path was not taken in P or if it was taken any number of 
% times in Q.  The path counts are set to the P count if the P count is 
% greater than 0 and the Q count is equal to zero.  Aggregate results are 
% calculated based on the these set difference counts.
% 
% CONDITION The condition evaluation counts are set to the counts in P 
% if the counts in Q are 0, otherwise they are set to 0. Aggregate results 
% are calculated based on the these set difference counts.


%   Copyright 1990-2019 The MathWorks, Inc.

p = cvdata(p);
q = cvdata(q);

% Perform consistency checking
p.checkDataCompatibility(q);

opFcn = @(x)((x(:,1)>0 & x(:,2)==0).*x(:,1));
out_metrics = perform_operation(p,q,opFcn,'-', []);

r = cvdata;
r.createDerivedData(p, q, out_metrics, []);

r.sfcnCovData = SlCov.results.CodeCovDataGroup.performOp(p.sfcnCovData, q.sfcnCovData, '-');
r.codeCovData = SlCov.results.CodeCovData.performOp(p.codeCovData, q.codeCovData, '-');
