Push(Value: Variant);
Value - value that should be placed to a stack.
The Push method places an element, which value is passed by the Value parameter, to a stack. The value is placed to the beginning of the stack.
Sub Main;
Var
Stack1: IStack;
i: Integer;
Begin
Stack1:=New Stack.Create;
For i:=0 To Math.RandBetweenI(50,100) Do
Stack1.Push("Value "+Math.RandBetweenI(0,100).ToString);
End For;
For i:=0 To Math.RandBetweenI(0,50) Do
Stack1.Pop;
End For;
i:=Stack1.Count;
End Sub Main;
After executing the example a stack of random elements is created, part of elements is extracted, and the "i" variable contains the number of elements left in the stack.
See also: