www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@guidarray/private/updateHash.m

    function obj = updateHash(obj, persistentHashState)
%UPDATEHASH Update the hash info for a guidarray
%
%  G = UPDATEHASH(G) updates the hash information for a guidarray.
%  G = UPDATEHASH(G, HASHSTATE) enables/disables the persistent hash
%  information.

%  Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc.


persistent hashState

% Two input arguments allows the obj hashing to be turned on and off
if nargin == 2
    hashState = persistentHashState;
    return
end

% Note the [] is treated as false and hence, by default, hashing is off
if hashState
    [sortedValues, sortedIndex] = sort(obj.values);
    obj.sortedValues = sortedValues;
    obj.sortedIndex  = uint32(sortedIndex);
else
    % Ensure that with hashing off we flag that no hash is stored
    if ~isempty(obj.sortedValues)
        obj.sortedValues = [];
        obj.sortedIndex  = [];
    end
end