Oracle Coherence for C++ API
Release 3.6.1.0
E18813-01

- Main Page
- Namespaces
- Classes
- Files

# coherence/lang/Comparable.hpp

    00001 /*
    00002 * Comparable.hpp
    00003 *
    00004 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    00005 *
    00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
    00007 * affiliates.
    00008 *
    00009 * This software is the confidential and proprietary information of Oracle
    00010 * Corporation. You shall not disclose such confidential and proprietary
    00011 * information and shall use it only in accordance with the terms of the
    00012 * license agreement you entered into with Oracle.
    00013 *
    00014 * This notice may not be removed or altered.
    00015 */
    00016 #ifndef COH_COMPARABLE_HPP
    00017 #define COH_COMPARABLE_HPP
    00018
    00019 #include "coherence/lang/compatibility.hpp"
    00020
    00021 #include "coherence/lang/interface_spec.hpp"
    00022 #include "coherence/lang/Object.hpp"
    00023 #include "coherence/lang/TypedHandle.hpp"
    00024
    00025 COH_OPEN_NAMESPACE2(coherence,lang)
    00026
    00027
    00028 /**
    00029 * This interface imposes a total ordering on the objects of each class that
    00030 * implements it. This ordering is referred to as the class's <i>natural
    00031 * ordering</i>, and the class's <tt>compareTo</tt> method is referred to as
    00032 * its <i>natural comparison method</i>.
    00033 *
    00034 * @author jh  2008.02.27
    00035 */
    00036 class COH_EXPORT Comparable
    00037     : public interface_spec<Comparable>
    00038     {
    00039     // ----- Comparable interface -------------------------------------------
    00040
    00041     public:
    00042         /**
    00043         * Compare this object with the specified object for order. Return a
    00044         * negative integer, zero, or a positive integer if this object is
    00045         * less than, equal to, or greater than the specified object.
    00046         *
    00047         * It is strongly recommended, but <i>not</i> strictly required, that
    00048         * <tt>(x->compareTo(y) == 0) == (x->equals(y))</tt>.
    00049         *
    00050         * @param v  the Object to be compared
    00051         *
    00052         * @return a negative integer, zero, or a positive integer if this
    00053         *         object is less than, equal to, or greater than the
    00054         *         specified object
    00055         *
    00056         * @throws ClassCastException if the specified Object's type prevents it
    00057         *         from being compared to this Object
    00058         */
    00059         virtual int32_t compareTo(Object::View v) const = 0;
    00060
    00061         /**
    00062         * Standard C++ less-than operator delegate.
    00063         *
    00064         * @param v  the Object to be compared
    00065         *
    00066         * @return true if this object is less than the specified object
    00067         */
    00068         virtual bool operator<(Object::View v) const
    00069             {
    00070             return compareTo(v) < 0;
    00071             }
    00072     };
    00073
    00074 COH_CLOSE_NAMESPACE2
    00075
    00076 #endif // COH_COMPARABLE_HPP

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.