Listenpaket++ 2008-12-08 15:30:53 function Anzahl (L : Liste) return Natural is I : Natural := 0; E : Ref_Element; begin if L.Anfang = null and L.Ende = null then return 0; else E := L.Anfang; loop I := I + 1; exit when (E.all.Nach = null); E := E.all.Nach; end loop; return I; end if; end Anzahl; function Gib_Element (L : Liste; N : Positive) return Inhalts_Typ is I : Natural := 0; E : Ref_Element; Rueckgabe : Inhalts_Typ; begin if L.Anfang /= null and L.Ende /= null then E := L.Anfang; loop I := I + 1; if N = I then Rueckgabe := E.all.Inhalt; exit; end if; exit when (E.all.Nach = null); E := E.all.Nach; end loop; end if; return Rueckgabe; end Gib_Element; function Gib_Erstes_Element (L : Liste) return Inhalts_Typ is begin return Gib_Element (L, 1); end Gib_Erstes_Element; function Gib_Letztes_Element (L : Liste) return Inhalts_Typ is begin return Gib_Element (L, Anzahl (L)); end Gib_Letztes_Element; procedure Liste_Leeren (L : in out Liste) is begin -- TODO Speicherplatz freigeben L := Neue_Liste; end Liste_Leeren; function Suche_Element (L : Liste; Inhalt : Inhalts_Typ; Neu : Boolean := False) return Natural is I : Natural := 0; E : Ref_Element := L.Anfang; Gefunden : Boolean := False; begin if L.Anfang /= null and L.Ende /= null then loop -- TODO end loop; end if; if Gefunden then return I; elsif Neu then Anhaengen_Hinten (L, Inhalt); return Anzahl (L); else return 0; end if; end Suche_Element; -- TODO Loesche_Element