我正在尝试实现dos_key_exist,我认为下面的代码可以做到。但我得到一个编译错误 key not found 行:Result := not (x.key = key)
does_key_exist(key: attached STRING):BOOLEAN
do
Result := not data.item(hash(key)).for_all (agent (x:like pair_at):BOOLEAN
do
Result := not equal(x.key, key)
end)
end
定义:
pair_at(key:attached STRING):TUPLE[key:STRING;value: like value_at]
require
does_key_exist(key)
deferred
ensure
end
list_at(key:STRING) : LINKED_LIST[like pair_at]
require
does_key_exist(key)
end
data : ARRAY[like list_at]