[Index for tmp_for_tar/dumper]
[Return to Master Index]
cmpstruct
(tmp_for_tar/dumper/cmpstruct.m)
Function Synopsis
c = cmpstruct(s1,s2)
Help text
c = cmpstruct (s1,s2) - Compare structs
Compares two structs, returning 1 if they are equal, 0 otherwise.
Will work only if fields of s1 and s2 can be compared through the
'cmpany' function.
See also fields, getfield, setfield, rmfield, isfield, isstruct,
struct.
Has not been optimized.
Last modified: January 2000
Listing of function file tmp_for_tar/dumper/cmpstruct.m
## c = cmpstruct (s1,s2) - Compare structs
##
## Compares two structs, returning 1 if they are equal, 0 otherwise.
##
## Will work only if fields of s1 and s2 can be compared through the
## 'cmpany' function.
##
## See also fields, getfield, setfield, rmfield, isfield, isstruct,
## struct.
##
## Has not been optimized.
## Author: Etienne Grossmann <etienne@isr.ist.utl.pt>
## Last modified: January 2000
function c = cmpstruct(s1,s2)
c = 1 ;
verbose = 0 ;
if !is_struct(s1) || !is_struct(s2) ,
printf('cmpstruct called with non-struct\n') ;
keyboard
end
for [val,key] = s1 ,
# if ! struct_contains(s2,key) ||...
# eval(sprintf( ...
# 'any(size(s1.%s)!=size(s2.%s)) || any(any(s1.%s != s2.%s));',...
# key,key,key,key) ) ,
# c = 0 ; return ;
# end
if ! struct_contains(s2,key) ||...
! eval(sprintf("cmpany(s1.%s,s2.%s);",key,key)) ,
sayif(verbose,"cmpstruct : Values for '%s' differ\n",key) ;
c = 0 ; return ;
end
sayif(verbose>1,"cmpstruct : Values for '%s' are equal\n",key) ;
end
for [val,key] = s2 ,
# if ! struct_contains(s1,key) ||...
# eval(sprintf(...
# 'any(size(s1.%s)!=size(s2.%s)) || any(any(s1.%s != s2.%s));',...
# key,key,key,key) ) ,
# c = 0 ; return ;
# end
if ! struct_contains(s1,key) ||...
! eval(sprintf("cmpany(s1.%s,s2.%s);",key,key)) ,
sayif(verbose,"cmpstruct : Values for '%s' differ\n",key) ;
c = 0 ; return ;
end
sayif(verbose>1,"cmpstruct : Values for '%s' are equal\n",key) ;
end
Produced by oct2html on Tue Aug 7 17:33:07 2001
Cross-Directory links are: ON