EiffelBase class
(HTML page generated by ISE Eiffel 4.2)
Eiffel Class
indexing
description: "Stacks (last-in, first-out dispensers), without commitment to a particular representation";
status: "See notice at end of class";
names: stack, dispenser;
access: fixed, lifo, membership;
contents: generic;
date: "$Date: 2007-03-30 19:10:11 +0000 (Fri, 30 Mar 2007) $";
revision: "$Revision: 95354 $"
deferred class STACK [G]
inherit
DISPENSER [G]
export
{NONE} prune, prune_all
redefine
extend, force, put, fill
end
feature -- Element change
extend (v: like item) is
-- Push v onto top.
-- Was declared in STACK as synonym of extend, force and put.
deferred
ensure
item_pushed: item = v
end;
force (v: like item) is
-- Push v onto top.
-- Was declared in STACK as synonym of extend, force and put.
deferred
ensure
item_pushed: item = v
end;
put (v: like item) is
-- Push v onto top.
-- Was declared in STACK as synonym of extend, force and put.
deferred
ensure
item_pushed: item = v
end;
replace (v: like item) is
-- Replace top item by v.
do
remove;
extend (v)
end;
fill (other: LINEAR [G]) is
-- Fill with as many items of other as possible.
-- Fill items with greatest index from other first.
-- Items inserted with lowest index (from other) will
-- always be on the top of stack.
-- The representations of other and current structure
-- need not be the same.
local
temp: ARRAYED_STACK [G]
do
create temp.make (0);
from
other.start
until
other.off
loop
temp.extend (other.item);
other.forth
end;
from
until
temp.empty or else notextendible
loop
extend (temp.item);
temp.remove
end
end;
end -- class STACK
|