indexing
	description: "Structures that can be extended"
	library: "Gobo Eiffel Structure Library"
	author: "Eric Bezault <ericb@gobo.demon.co.uk>"
	copyright: "Copyright (c) 1997, Eric Bezault"
deferred class interface
	DS_EXTENDIBLE [G]
feature -- Access
	item: G
			-- Item in structure
		require
			not_empty: not is_empty
	
feature -- Measurement
	count: INTEGER
			-- Number of items in structure
			-- (from DS_CONTAINER)
	
feature -- Comparison
	is_equal (other: like Current): BOOLEAN
			-- Is current structure equal to other?
			-- (from DS_CONTAINER)
		require -- from GENERAL
			other_not_void: other /= void
		ensure -- from GENERAL
			symmetric: Result implies other.is_equal (Current);
			consistent: standard_is_equal (other) implies Result
		ensure then -- from DS_CONTAINER
			same_count: Result implies count = other.count
	
feature -- Status report
	extendible (n: INTEGER): BOOLEAN
			-- May structure be extended with n items?
		require
			positive_n: n >= 0
	is_empty: BOOLEAN
			-- Is structure empty?
			-- (from DS_CONTAINER)
	
feature -- Element change
	append (other: DS_LINEAR [G])
			-- Add items of other to structure.
		require
			other_not_void: other /= void
		ensure
			new_count: count = old count + other.count
	extend (other: DS_LINEAR [G])
			-- Add items of other to structure.
		require
			other_not_void: other /= void;
			extendible: extendible (other.count)
		ensure
			new_count: count = old count + other.count
	force (v: G)
			-- Add v to structure.
		ensure
			one_more: count = old count + 1
	put (v: G)
			-- Add v to structure.
		require
			extendible: extendible (1)
		ensure
			one_more: count = old count + 1
	
feature -- Removal
	keep (n: INTEGER)
			-- Keep n items in structure.
		require
			valid_n: 0 <= n and n <= count
		ensure
			new_count: count = n
	prune (n: INTEGER)
			-- Remove n items from structure.
		require
			valid_n: 0 <= n and n <= count
		ensure
			new_count: count = old count - n
	remove
			-- Remove an item from structure.
		require
			not_empty: not is_empty
		ensure
			one_less: count = old count - 1
	wipe_out
			-- Remove all items from structure.
			-- (from DS_CONTAINER)
		ensure -- from DS_CONTAINER
			wipe_out: is_empty
	
invariant
		-- from GENERAL
	reflexive_equality: standard_is_equal (Current);
	reflexive_conformance: conforms_to (Current);
		-- from DS_CONTAINER
	positive_count: count >= 0;
	empty_definition: is_empty = (count = 0);
end -- class DS_EXTENDIBLE