-- Copyright 1993-1998, by the Cecil Project -- Department of Computer Science and Engineering, University of Washington -- See the LICENSE file for license information. --DOC Stacks are implemented as special interfaces to mutable lists. template object stack[T]; private extend stack[`T] isa m_list[T]; method collection_name(@:stack[`T]):string { "stack" } method push(s@:stack[`T], x:T):void { add_first(s, x); } method pop(s@:stack[`T]):T { remove_first(s) } method top(s@:stack[`T]):T { first(s) } method copy(s@:stack[`T]):stack[T] { let new:stack[T] := new_stack[T](); s.do(&(x:T){ new.add_last(x); }); new } method new_stack[T]():stack[T] { concrete object isa stack[T] }