note
	description: "Interface for buffers"
	library: "Gobo Eiffel Kernel Library"
	copyright: "Copyright (c) 2001-2012, Eric Bezault and others"
	license: "MIT License"
	date: "$Date: 2016-05-06 19:15:38 +0000 (Fri, 06 May 2016) $"
	revision: "$Revision: 98678 $"

deferred class interface
	KI_BUFFER [G]

feature -- Access

	item (i: INTEGER_32): G
			-- Item at position i
		require
			i_large_enough: i >= 1
			i_small_enough: i <= count
	
feature -- Measurement

	count: INTEGER_32
			-- Number of items in buffer
		ensure
			count_positive: Result >= 0
	
feature -- Element change

	put (v: G; i: INTEGER_32)
			-- Replace item at position i by v.
		require
			i_large_enough: i >= 1
			i_small_enough: i <= count
		ensure
			inserted: item (i) = v

	fill_from_stream (a_stream: KI_INPUT_STREAM [G]; pos, nb: INTEGER_32): INTEGER_32
			-- Fill buffer, starting at position pos, with
			-- at most nb items read from a_stream.
			-- Return the number of items actually read.
		require
			a_stream_not_void: a_stream /= Void
			a_stream_open_read: a_stream.is_open_read
			not_end_of_input: not a_stream.end_of_input
			pos_large_enough: pos >= 1
			nb_large_enough: nb > 0
			enough_space: (pos + nb - 1) <= count
		ensure
			nb_item_read_large_enough: Result >= 0
			nb_item_read_small_enough: Result <= nb
			not_end_of_input: not a_stream.end_of_input implies Result > 0

	move_left (old_pos, new_pos: INTEGER_32; nb: INTEGER_32)
			-- Copy nb items from old_pos to
			-- new_pos in buffer.
		require
			nb_positive: nb >= 0
			old_pos_large_enough: old_pos >= 1
			enough_characters: (old_pos + nb - 1) <= count
			new_pos_large_enough: new_pos >= 1
			enough_space: (new_pos + nb - 1) <= count
			move_left: old_pos > new_pos

	move_right (old_pos, new_pos: INTEGER_32; nb: INTEGER_32)
			-- Copy nb items from old_pos to
			-- new_pos in buffer.
		require
			nb_positive: nb >= 0
			old_pos_large_enough: old_pos >= 1
			enough_characters: (old_pos + nb - 1) <= count
			new_pos_large_enough: new_pos >= 1
			enough_space: (new_pos + nb - 1) <= count
			move_right: old_pos < new_pos
	
feature -- Resizing

	resize (n: INTEGER_32)
			-- Resize buffer so that it contains n items.
			-- Do not lose any previously entered items.
		require
			n_large_enough: n >= count
		ensure
			count_set: count = n
	
end -- class KI_BUFFER

Generated by ISE EiffelStudio