indexing
description: "Routines that ought to be in class ARRAY"
library: "Gobo Eiffel Kernel Library"
author: "Eric Bezault <ericb@gobo.demon.co.uk>"
copyright: "Copyright (c) 1998, Eric Bezault"
class interface
KL_ARRAY_ROUTINES [G]
feature -- Initialization
make_from_array (an_array: ARRAY [G]; min_index: INTEGER): ARRAY [G]
-- Create a new array and initialize it
-- with items from an_array.
require
an_array_not_void: an_array /= void
ensure
array_not_void: Result /= void;
lower_set: Result.lower = min_index;
count_set: Result.count = an_array.count
feature -- Access
subarray (an_array: ARRAY [G]; start_pos, end_pos, min_index: INTEGER): ARRAY [G]
-- Array made up of items from an_array within
-- bounds start_pos and end_pos
require
an_array_not_void: an_array /= void;
start_pos_large_enough: start_pos >= an_array.lower;
end_pos_small_enough: end_pos <= an_array.upper;
valid_bounds: start_pos <= end_pos + 1
ensure
array_not_void: Result /= void;
lower_set: Result.lower = min_index;
count_set: Result.count = end_pos - start_pos + 1
feature -- Status report
has (an_array: ARRAY [G]; v: G): BOOLEAN
-- Does v appear in an_array?
require
an_array_not_void: an_array /= void
feature -- Element change
subcopy (an_array, other: ARRAY [G]; start_pos, end_pos, index_pos: INTEGER)
-- Copy items of other within bounds start_pos and end_pos
-- to an_array starting at index index_pos.
require
an_array_not_void: an_array /= void;
other_not_void: other /= void;
not_same: an_array /= other;
start_pos_large_enough: start_pos >= other.lower;
end_pos_small_enough: end_pos <= other.upper;
valid_bounds: start_pos <= end_pos + 1;
index_pos_large_enough: index_pos >= an_array.lower;
enough_space: (an_array.upper - index_pos) >= (end_pos - start_pos)
feature -- Removal
clear_all (an_array: ARRAY [G])
-- Reset all items to default values.
require
an_array_not_void: an_array /= void
invariant
-- from GENERAL
reflexive_equality: standard_is_equal (Current);
reflexive_conformance: conforms_to (Current);
end -- class KL_ARRAY_ROUTINES