function checkSPSortingDuplicates(sp,op,messageHasHole)
%MATLAB Code Generation Private Function
%
%    Verifies that sp is sorted in ascending order and does not contain 
%    duplicates. This function can be used with datetime or duration sample
%    points.
%
%#codegen

%   Copyright 2020-2023 The MathWorks, Inc.
coder.inline('always');
coder.internal.prefer_const(sp,op);
if nargin <= 2
    messageHasHole = true;
else
    coder.internal.prefer_const(messageHasHole);
end
if ~isempty(sp) && ~isscalar(sp)
    strictlyIncreasing = isStrictlyIncreasing(sp);
    if ~strictlyIncreasing
        if messageHasHole
            coder.internal.assert(~hasConsecutiveDuplicates(sp),['MATLAB:' op ':SamplePointsDuplicate'],'''SamplePoints''');
            coder.internal.assert(strictlyIncreasing,['MATLAB:' op ':SamplePointsSorted'],'''SamplePoints''');
        else
            coder.internal.assert(~hasConsecutiveDuplicates(sp),['MATLAB:' op ':SamplePointsDuplicate']);
            coder.internal.assert(strictlyIncreasing,['MATLAB:' op ':SamplePointsSorted']);
        end
    end
end
end

% LocalWords:  sp
