gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/+matlab/+bigdata/+internal/+adaptors/TallSize.m

    %TallSize object that represents a size in the tall dimension

% Copyright 2016 The MathWorks, Inc.

classdef TallSize < handle

    properties
        % Scalar double indicating size, or NaN if not known
        Size = NaN
    end
    properties (SetAccess = immutable)
        % Id of this tall size to make it easier to check whether size information is
        % being propagated.
        Id
    end
    methods
        function obj = TallSize(val)
            obj.Id = iNextId();
            if nargin > 0
                obj.Size = val;
            end
        end
        
        function set.Size(obj, newVal)
        % Update the size - must be scalar double
            assert(isscalar(newVal) && isa(newVal, 'double'));

            % Size must either be changing field away from NaN, or match the old value.
            assert(isnan(obj.Size) || obj.Size == newVal);
            obj.Size = newVal;
        end
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function id = iNextId()
    persistent ID
    if isempty(ID)
        ID = 1;
    end
    id = ID;
    ID = 1 + ID;
end