BTreePURPOSEBalanced tree constructor.
SYNOPSISfunction T=BTree(varargin)
DESCRIPTIONBalanced tree constructor. Builds a new balanced tree of poses. The balanced tree consructor can be used with the following parameters - Another balanced tree. Copy constructor. - A data set in the form of a cell array (possibly empty) and the number indicating the expected number of elements to be stored in the tree. CROSS-REFERENCE INFORMATIONThis function calls:
SOURCE CODE0001 function T=BTree(varargin) 0002 % Balanced tree constructor. 0003 % 0004 % Builds a new balanced tree of poses. 0005 % 0006 % The balanced tree consructor can be used with the following parameters 0007 % - Another balanced tree. Copy constructor. 0008 % - A data set in the form of a cell array (possibly empty) and the 0009 % number indicating the expected number of elements to be stored in 0010 % the tree. 0011 0012 switch nargin 0013 0014 case 1 0015 if isa(varargin{1},'BTree') 0016 T=varargin{1}; 0017 else 0018 if isa(varargin{1},'cell') 0019 % Reserve space for 2500 poses. This array will be extended as 0020 % needed. 0021 T=BTree(varargin{1},5000); 0022 else 0023 error('Wrong number of parameters in Balanced-Tree creation'); 0024 end 0025 end 0026 0027 case 2 0028 if isa(varargin{1},'cell') && isa(varargin{2},'double') 0029 0030 data=varargin{1}; 0031 nd=size(data,2); % number of elements to initially insert in the tree 0032 0033 n=max(3*nd,varargin{2}); 0034 T.data=cell(1,n); 0035 T.last=0; 0036 T.leaves=[]; 0037 T.root=0; 0038 T=class(T,'BTree'); 0039 0040 for i=1:nd 0041 T=InsertInTree(T,data{i}); 0042 end 0043 0044 else 0045 error('Wrong parameters type in Balanced-Tree creation'); 0046 end 0047 0048 otherwise 0049 error('Wrong number of parameters in Balanced-Tree creation'); 0050 end |