EiffelBase class
(HTML page generated by ISE Eiffel 4.2)
Eiffel Class
indexing
description: "Finite sequences: structures where existing items are arrangedand accessed sequentially, and new ones can be added at the end.";
status: "See notice at end of class";
names: sequence;
access: cursor, membership;
contents: generic;
date: "$Date: 2007-03-30 11:10:11 -0800 (Fri, 30 Mar 2007) $";
revision: "$Revision: 95354 $"
deferred class SEQUENCE [G]
inherit
ACTIVE [G]
redefine
prune_all
end;
BILINEAR [G];
FINITE [G]
feature -- Status report
readable: BOOLEAN is
-- Is there a current item that may be read?
do
Result := notoff
end;
writable: BOOLEAN is
-- Is there a current item that may be modified?
do
Result := notoff
end;
feature -- Element change
force (v: like item) is
-- Add v to end.
require
extendible: extendible
do
extend (v)
ensure
new_count: count = old count + 1;
item_inserted: has (v)
end;
append (s: SEQUENCE [G]) is
-- Append a copy of s.
require
argument_not_void: s /= void
local
l: like s
do
if s = Current then
l := deep_clone (s)
else
l := s
end;
from
l.start
until
l.exhausted
loop
extend (l.item);
l.forth
end
ensure
new_count: count >= old count
end;
put (v: like item) is
-- Add v to end.
do
extend (v)
ensure
new_count: count = old count + 1
end;
feature -- Removal
prune (v: like item) is
-- Remove the first occurrence of v if any.
-- If no such occurrence go off.
do
start;
search (v);
if notexhausted then
remove
end
end;
prune_all (v: like item) is
-- Remove all occurrences of v; go off.
do
from
start
until
exhausted
loop
search (v);
if notexhausted then
remove
end
end
end;
end -- class SEQUENCE
|