Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Passing function to a class

843793May 19 2002 — edited Jul 15 2002
Hi !

Due to the genericity, it's possible to be in the situation of the incapacity to compare 2 objects of a user define type because the comparision field may be a special attribute in the object "type". So, is it possible to pass a compare function to a class to do the comparision ?!

Example :

In a BinaryTree class, I want to store object containing these attributes : ReferenceNumber, Name, Price. The insertion criteria in the binary tree is on the ReferenceNumber attribute. In the generic BinaryTree class, I will not know that this attribute exist because it's generic... so I want to pass to the class the functions "Equal", "LessThan" and "GreaterThan" who will compare the user define type, in the generic class.

Can I do it and if so, How can I do it ?!

Thanks !!

Pascal ;

Comments

Alanc-Oracle

The <threads.h> header from C11 is only available on Solaris 11.4. Older versions of Solaris do not have C11 support and require using the POSIX threads API instead.

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 12 2002
Added on May 19 2002
4 comments
118 views