Home > functions > common > utility > vb_util_is_included_list.m

vb_util_is_included_list

PURPOSE ^

check whether target list is included by base list

SYNOPSIS ^

function [result, idx] = vb_util_is_included_list(base, target)

DESCRIPTION ^

 check whether target list is included by base list
 [usage]
   [result, idx] = vb_util_is_included_list(base, target)
 [input]
     base : <required> base list. both numerical and string
   target : <required> target list. both numerical and string.
          :  but its type must be the same as base list
 [output]
   result : <boolean>
          :   true : base includes all the elments of target
          :  false : all the elements of target are not included in base
      idx : corresponding index of base list
 [note]
   @see vb_util_check_numerical_lists.m
   @see vb_util_check_string_lists.m
 [history]
   2008-02-13 (Sako) initial version

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [result, idx] = vb_util_is_included_list(base, target)
0002 % check whether target list is included by base list
0003 % [usage]
0004 %   [result, idx] = vb_util_is_included_list(base, target)
0005 % [input]
0006 %     base : <required> base list. both numerical and string
0007 %   target : <required> target list. both numerical and string.
0008 %          :  but its type must be the same as base list
0009 % [output]
0010 %   result : <boolean>
0011 %          :   true : base includes all the elments of target
0012 %          :  false : all the elements of target are not included in base
0013 %      idx : corresponding index of base list
0014 % [note]
0015 %   @see vb_util_check_numerical_lists.m
0016 %   @see vb_util_check_string_lists.m
0017 % [history]
0018 %   2008-02-13 (Sako) initial version
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 % --- CHECK ARGUMENTS --- %
0024 if ~exist('base', 'var'), base = []; end
0025 if ~exist('target', 'var'), target = []; end
0026 [base, target, mode] = inner_check_arguments(base, target);
0027 
0028 % --- MAIN PROCEDURE --------------------------------------------------------- %
0029 %
0030 switch mode
0031   case 1 % numerical list
0032     [result, idx] = vb_util_check_numerical_lists(base, target);
0033   case 2 % string list
0034     [result, idx] = vb_util_check_string_lists(base, target);
0035   otherwise
0036     result = false;
0037     idx = [];
0038 end
0039 return;
0040 %
0041 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0042 
0043 % --- INNER FUNCTIONS -------------------------------------------------------- %
0044 %
0045 % --- inner_check_arguments()
0046 %
0047 function [base, target, mode] = inner_check_arguments(base, target)
0048 func_ = mfilename;
0049 if isempty(base)
0050   error('(%s)base is a required parameter', func_);
0051 end
0052 if isempty(target)
0053   error('(%s)target is a required parameter', func_);
0054 end
0055 
0056 % decide mode - 1) numeric 2) string 3) different type
0057 if isnumeric(base) && isnumeric(target)
0058   mode = 1; % numerical list
0059 elseif ~isnumeric(base) && ~isnumeric(target)
0060   mode = 2; % string list
0061 else
0062   mode = 3; % types are different
0063 end
0064 return;
0065 %
0066 % --- end of inner_check_arguments()
0067 %
0068 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0069 
0070 
0071 %%% END OF FILE %%%

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005