📄 flush.m
字号:
function tree = flush(tree,uid)
% XMLTREE/FLUSH Flush (Clear a subtree given its UID)
%
% tree - XMLTree object
% uid - array of UID's of subtrees to be cleared
% Default is root
%_______________________________________________________________________
%
% Clear a subtree given its UID (remove all the leaves of the tree)
% The tree parameter must be in input AND in output
%_______________________________________________________________________
% @(#)flush.m Guillaume Flandin 02/04/10
error(nargchk(1,2,nargin));
if nargin == 1,
uid = root(tree);
end
uid = uid(:);
for i=1:length(uid)
tree = sub_flush(tree,uid(i));
end
%=======================================================================
function tree = sub_flush(tree,uid)
if isfield(tree.tree{uid},'contents')
% contents is parsed in reverse order because each child is
% deleted and the contents vector is then eventually reduced
for i=length(tree.tree{uid}.contents):-1:1
tree = sub_flush(tree,tree.tree{uid}.contents(i));
end
end
if strcmp(tree.tree{uid}.type,'chardata') |...
strcmp(tree.tree{uid}.type,'pi') |...
strcmp(tree.tree{uid}.type,'cdata') |...
strcmp(tree.tree{uid}.type,'comment')
tree = delete(tree,uid);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -