vahlberg@cs.uq.oz.au (Jon Vahlberg) (06/01/91)
Hello, I've got a slight problem with an eiffel program and I am not to sure how to solve it. I would appreciate it if someone could tell me a solution. The problem in hand is that, I want a generic class (let's call it XSet) which takes any type. It is basically a set of elements. Now, I want an operation called In, which given an element, tests to see whether the element is in the set. Sounds easy enough so far. Now the problem is these elements may have attributes which are strings and I would like to test each the members of the set based on the contents of these attributes, not on their references, for the element. I have written and can assume for all members being passed that they have the function Equal defined for them. Either it has been explicitly defined or just inherited from Any. Those types which have strings for attributes, have Equal defined in them, that does the testing on the contents of the string (whereas Equal in ANY just checks the reference value). The major problem is that in the operation In, where I use the operation Equal to test, it uses the operation Equal from Any and not from the one defined for the element. Is there a nice, clean way around it? If this problem is stated too ambiguously, send me a email and I'll discuss it further. Jon.