INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "The class to store objects in the array in the file"
project: "Visual Eiffel Library"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: pool
class PERSISTENT_ARRAY [G]
inherit

MEMORY
rename
dispose as close
redefine
close
end
creation

make_create_read_write,
make_general_create_read_write,
make_open_read,
make_open_read_write
feature -- Operations

put (element: G; index: INTEGER)
-- Replace 'index'-th entry by 'element'
require
connected: is_connected
positive_index: index > 0
extendible: extendible

item (index: INTEGER): G
-- Entry at index 'index', if in interval
require
connected: is_connected
positive_index: index >= 1

close
-- Close the file

put_range (range: ARRAY [G]; lower, upper: INTEGER)
-- Put the first object in array 'range'
-- (i.e. range.item (range.lower)) at position
-- 'lower' in the current object, the next object
-- at position 'lower' + 1, etc.
require
connected: is_connected
positive_index: lower > 0
valid_range: lower <= upper - 1
range_not_void: range /= void
range_big_enough: upper - lower <= range.upper - range.lower
extendible: extendible

item_range (lower, upper: INTEGER): ARRAY [G]
-- Build an array with index range [lower, upper]
-- containing the objects from corresponding
-- positions in the current object.
require
connected: is_connected
positive_index: lower > 0
valid_range: lower <= upper - 1
feature -- Status

is_connected: BOOLEAN
-- Is the file open?

extendible: BOOLEAN
-- May new items be added?

count: INTEGER
-- Number of items in the array
require
connected: is_connected

is_general: BOOLEAN
-- Was "general" store used?
require
connected: is_connected
feature {NONE}-- Creation procedures

make_create_read_write (file_name: STRING)
-- Create file object with 'file_name' as file name
-- and open file for both reading and writing;
-- create it if it does not exist
require
non_void_file_name: file_name /= void

make_general_create_read_write (file_name: STRING)
-- Create file object with 'file_name' as file name
-- and open file for both reading and writing;
-- create it if it does not exist
-- Use "general" store mechanism
require
non_void_file_name: file_name /= void

make_open_read (file_name: STRING)
-- Create file object with 'file_name' as file name
-- and open file in read mode
require
non_void_file_name: file_name /= void

make_open_read_write (file_name: STRING)
-- Create file object with 'file_name' as file name
-- and open file for both reading and writing
require
non_void_file_name: file_name /= void
end -- class PERSISTENT_ARRAY

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES