stack class : Copy() method

Description

Gets a copy of the caller stack.

Syntax

stackInstance.Copy()

Arguments

None

Return value

ClassDescription
some stackA copied stack.

Sample code

stack{int} orgStack = new stack{int}();

orgStack.Push(10);

orgStack.Push(8);

orgStack.Push(9);

stack{int} newStack = orgStack.Copy();

newStack.Pop(); // 9

newStack.Pop(); // 8

newStack.Pop(); // 10

//---------------

orgStack.Pop(); // 9

orgStack.Pop(); // 8

orgStack.Pop(); // 10

Notes

This method is added in Ver 1.1.0.0.

The returned stack is a shallow copy of the caller stack. That is, the caller and the returned stack refer to the same element.

Links for reference

None

Copyright © Rice All rights reserved.