class GBN_KEYED_PAIR [G->COMPARABLE, H] -- Ordered pair consisting of key and data. -- The key cannot be changed after creation, -- but key and item can be read and item -- changed at any time. inherit COMPARABLE redefine is_equal, out end -- necessary to redefine is_equal because -- of ensure condition involving trichotomy. creation make feature is_equal ( other : like Current ) : BOOLEAN is do Result := key . is_equal ( other . key ) end infix "<" (other: like Current): BOOLEAN is do Result := (key < other . key) end key : G item : H make ( k: G ) is do key := k end put ( titem: H ) is do item := titem end out : STRING is do -- changed to_string to out, because -- to_string not recognised in STRING! !! Result . copy ( "( " ) Result . append ( key . out ) Result . append ( ", " ) Result . append ( item . out ) Result . append ( " )" ) end end -- class GBN_KEYED_PAIR