Eiffel でlinked_listのイテレータを作成しようとしています。
次のエラーが表示されます:変数が正しく設定されていません。
Class: ITERATOR_ON_COLLECTION [E]
Feature: make
Attribute(s): {ITERATOR}.target
Line: 30
ボイドセーフティが原因であることはわかっていますが、修正方法がわかりません。(void safe を True に設定し、プリコンパイル済みライブラリを safe バージョンに変更して clean_compile しました。)
以下はクラスです。
class
ITERATOR_ON_COLLECTION [E]
inherit
ITERATOR [E]
create
make
feature {NONE} -- Attributes
collection: LINKED_LIST[E]
item_index: INTEGER
feature -- initialization
make(c: LINKED_LIST [E])
require
--c /= void
do
-- create {COLLECTION} collection.make
-- create collection.make -- it doesnt work with/without this line
collection := c
item_index := 1
end
start
do
item_index := 1
end
item: STRING
do
Result := "hello"
end
next
do
item_index := item_index + 1
end
is_off: BOOLEAN
do
Result := True
end
do_until (action: PROCEDURE [E]; test: FUNCTION [E, BOOLEAN])
-- Apply `action' to every item of `target' up to
-- and including first one satisfying `test'.
-- (Apply to full list if no item satisfies `test').
require else
action_exists: action /= Void
test_exists: test /= Void
do
end
do_while (action: PROCEDURE [E]; test: FUNCTION [E, BOOLEAN])
-- Apply `action' to every item of `target' up to
-- and including first one not satisfying `test'.
-- (Apply to full list if all items satisfy `test').
require else
action_exists: action /= Void
test_exists: test /= Void
do
end
until_do (action: PROCEDURE [E]; test: FUNCTION [E, BOOLEAN])
-- Apply `action' to every item of `target' up to
-- but excluding first one satisfying `test'.
-- (Apply to full list if no items satisfy `test'.)
require else
action_exists: action /= Void
test_exists: test /= Void
do
end
while_do (action: PROCEDURE [E]; test: FUNCTION [E, BOOLEAN])
-- Apply `action' to every item of `target' up to
-- but excluding first one satisfying not `test'.
-- (Apply to full list if all items satisfy `test'.)
require else
action_exists: action /= Void
test_exists: test /= Void
do
end
there_exists (test: FUNCTION [E, BOOLEAN]): BOOLEAN
-- Is `test' true for at least one item of `target'?
require else
test_exists: test /= Void
do
end
for_all (test: FUNCTION [E, BOOLEAN]): BOOLEAN
-- Is `test' true for all items of `target'?
require else
test_exists: test /= Void
do
end
end