Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/VDM/VDMPP/stackPP/     Datei vom 13.4.2020 mit Größe 482 B image not shown  

Quelle  stack.vdmpp   Sprache: VDM

 

class Stack

  instance variables
    stack : seq of int := [];

  operations

    public
    Reset : () ==> ()
    Reset () ==
      stack := [];

    public
    Pop : () ==> int
    Pop() ==
      def res = hd stack in
        (stack := tl stack;
         return res)
    pre stack <> []
    post stack~ = [RESULT]^stack;

    public Push: int ==> ()
    Push(elem) ==
      stack := stack ^[elem];

    public
    Top : () ==> int
    Top() ==
      return (hd stack);

end Stack

Messung
CHZG
8010010093

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland