------------------------------------------------------------------ -------------- ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real time scheduling analysis tool. -- This program provides services to automatically check performances -- of real time architectures. -- -- Copyright (C) 2002-2010, by Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- the LISyC Team, University of Western Britanny. -- -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ----------------------------------------------------------------------------- -- Last update : -- $Rev: 523 $ -- $Date: 2012-09-26 14:09:39 +0100 (Wed, 26 Sep 2012) $ -- $Author: fotsing $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package body binary_trees is function get_left (l : in binary_tree) return binary_tree is begin if l = null then raise no_cell; end if; return l.left; end get_left; function get_right (l : in binary_tree) return binary_tree is begin if l = null then raise no_cell; end if; return l.right; end get_right; procedure add_right (l : in out binary_tree; e : in element) is new_cell : binary_tree; begin new_cell := new cell; new_cell.info := e; if l = null then l := new_cell; else l.right := new_cell; end if; end add_right; procedure add_left (l : in out binary_tree; e : in element) is new_cell : binary_tree; begin new_cell := new cell; new_cell.info := e; if l = null then l := new_cell; else l.left := new_cell; end if; end add_left; procedure put (l : in binary_tree) is begin put (l.info); if (l.left /= null) then put (l.left); end if; if (l.right /= null) then put (l.right); end if; end put; procedure delete (l : in out binary_tree; e : in element) is --current : binary_tree := l; --previous : binary_tree; begin null; -- while current/=null loop -- if current.info=e -- then if (previous=null) -- then l:=current.left; -- else previous.left:=current.left; -- end if; -- exit; -- else previous:=current; -- current:=current.left; -- end if; -- end loop; end delete; procedure duplicate (src : in binary_tree; dest : in out binary_tree) is --current : binary_tree := src; --previous, new_tree : binary_tree; begin -- while current/=null loop -- new_tree:=new cell; -- new_tree.all:=current.all; -- if(previous/=null) -- then -- new_tree.left:=previous; -- else dest:=new_tree; -- end if; -- current:=current.left; -- previous:=new_tree; -- end loop; null; end duplicate; end binary_trees;