INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Simple string accumulator"
project: "Visual Eiffel"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: dale
class STRING_ACCUMULATOR
creation

make
feature -- Attributes:

index: INTEGER

strings: ARRAY [STRING]

states: ARRAY [INTEGER]

alert: INTEGER

threshold: INTEGER
feature -- Commands:

make
-- creation procedure

add (c: CHARACTER)
-- add character

append (s: STRING)
-- append string

next
-- shift on the next string, adding new if it's needed

reset
-- reset on the first string

erase
-- erase current string

wipe_out
-- wipe out the whole accumulator
ensure
well_done: count = 1

call_alert
-- increment alert count
ensure
valid_result: alert = alert + 1

relax
-- decrement alert count
require
positive_alert: 1 <= alert
ensure
valid_result: alert = alert - 1
feature -- Queries:

item (k: INTEGER): STRING
-- returns k-th string
require
valid_index: 1 <= k and then k <= index
ensure
not_void: Result /= void

having_state (n: INTEGER): ARRAY [STRING]
-- expose strings whose state is equal to 'n'
require
valid_state: n /= 0

count_state (n: INTEGER): INTEGER
-- count strings having the specified state
require
valid_state: n /= 0

merge_with_state (n: INTEGER): STRING
-- merge strings having the state 'n'
require
valid_state: n /= 0

current_string: STRING
-- returns current string

state (k: INTEGER): INTEGER
-- returns k-th state value
require
valid_index: 1 <= k and then k <= index
ensure
valid_state: Result /= 0

current_state: INTEGER
-- returns current state
ensure
valid_state: Result /= 0

count: INTEGER
-- total number of strings
feature -- Settings:

set_state (n: INTEGER)
-- set state for the current string
require
valid_state: n /= 0

set_alert (n: INTEGER)
-- set alert
require
valid_alert: 0 <= n

set_threshold (n: INTEGER)
-- set alert threshold
require
valid_threshold: 1 <= n
invariant

arrays_are_correlated: strings.count = states.count
end -- class STRING_ACCUMULATOR

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES