www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgddnode/remove.m

    function D = remove(D,thing)
%REMOVE  Remove an item from the Variable Dictionary
%
%  D = remove(D,ptr)
%  D = remove(D,name)

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



if isa(thing,'xregpointer')
    cgp = project(D);
    A = getConnections(cgp);
    for k = 1:length(thing)
        itemindx =  (thing(k) == D.ptrlist);
        if any(itemindx);
            if thing(k).issymvalue
                D.numsymvars = D.numsymvars - 1;
            end
            D.ptrlist = D.ptrlist(~itemindx);
            item = find(A,'pointer',thing(k));
            freeptr(thing(k));
            % remove item from connections
            A = removeItems(A,item);
            pointer(D);
        end
    end
    % update connections in project
    UpdateConnections(cgp,A);
else
    % name
    ptr = find(D, thing);
    if ~isempty(ptr)
        if strcmp(ptr.getname, thing)
            % Remove if the name matches
            D = remove(D, ptr);
        else
            % Remove alias
            ptr.info = ptr.removealias(thing);
            pointer(D);
        end
    end    
end