function thelist = insertList(thelist,object); %insertList - inserts an object into a list of objects % % Parameter: thelist The list to be modified % Parameter: object The object to be inserted % Returns: thelist The modified list % % Example(s): % thelist=insertList(thelist,object); % %% =========================================================================== %% =========================================================================== % Copyright (C): % 1999-2000 by Telia Research AB, Lulea, Sweden; % 2000-2002 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Project : FTW's xDSLsimu % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % : Bo Engstrom (bosse@upzide.com) % % CVS: $Id: insertList.m,v 3.1 2003/11/03 12:11:58 tono Exp $ %% =========================================================================== % Change History % 1999-02-25 (ToNo) Created % 2001-06-14 (Bosse) Octave port % 2002-07-01 (PeKa) Octave to Matlab compatibility port %% =========================================================================== len=length(thelist); if len==0, thelist=cell(1); thelist{1}=object; else found=0; found_pos=0; for i=1:length(thelist) found=strcmp(thelist{i}.name,object.name); if found found_pos=i; end end if (found_pos==0) % If new, add object to the end of the list thelist{len+1}=object; else % If existing overwrite the object % (Select first entry if list has multiple entries with the same name) thelist{found_pos}=object; found_pos=0; end end;