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

- Main Page
- Namespaces
- Classes
- Files

# coherence/util/Set.hpp

    00001 /*
    00002 * Set.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_SET_HPP
    00017 #define COH_SET_HPP
    00018
    00019 #include "coherence/lang.ns"
    00020
    00021 #include "coherence/util/Collection.hpp"
    00022
    00023 COH_OPEN_NAMESPACE2(coherence,util)
    00024
    00025
    00026 /**
    00027 * A collection that contains no duplicate elements.  As implied by
    00028 * its name, this interface models the mathematical <i>set</i> abstraction.
    00029 *
    00030 * The <tt>Set</tt> interface places additional stipulations on the contracts
    00031 * of all constructors of the <tt>Set</tt> implementations
    00032 * and on the contracts of the <tt>add</tt> and <tt>equals</tt> methods.
    00033 *
    00034 * The additional stipulation on constructors is, not surprisingly,
    00035 * that all constructors must create a set that contains no duplicate
    00036 * elements.
    00037 *
    00038 * @see Collection
    00039 */
    00040 class COH_EXPORT Set
    00041     : public interface_spec<Set,
    00042         implements<Collection> >
    00043     {
    00044     // ----- Collection interface -------------------------------------------
    00045
    00046     public:
    00047         /**
    00048         * Add the specified element to this set if it is not already present.
    00049         * If this set already contains the specified element, the call leaves
    00050         * this set unchanged and returns <tt>false</tt>.
    00051         * In combination with the restriction on constructors, this ensures
    00052         * that sets never contain duplicate elements.
    00053         *
    00054         * @param v element to be added to this set.
    00055         *
    00056         * @return <tt>true</tt> iff this set did not already contain
    00057         *         the specified element.
    00058         *
    00059         * @throws coherence::lang::UnsupportedOperationException
    00060         *         if the #add() operation is not supported by this
    00061         *         collection.
    00062         */
    00063         using Collection::add;
    00064
    00065
    00066     // ----- Object interface -----------------------------------------------
    00067
    00068     public:
    00069         /**
    00070         * Compare the specified object with this set for equality.  Return
    00071         * <tt>true</tt> if the specified object is also a set, the two sets
    00072         * have the same size, and every member of the specified set is
    00073         * contained in this set (or equivalently, every member of this set is
    00074         * contained in the specified set). This definition ensures that the
    00075         * equals() method works properly across different implementations of
    00076         * the Set interface.
    00077         *
    00078         * @param v {@link coherence::lang::Object Object} to be compared
    00079         *          for equality with this set.
    00080         *
    00081         * @return @c true iff the specified Object is equal to this set.
    00082         */
    00083         using Object::equals;
    00084
    00085         /**
    00086         * Return the hash code value for this set.  The hash code of a set
    00087         * is defined to be the sum of the hash codes of the elements in
    00088         * the set, where the hashcode of a <tt>NULL</tt> element is defined
    00089         * to be zero. This ensures that <code>s1->equals(s2)</code> implies
    00090         * that <code>s1->hashCode() == s2->hashCode()</code> for any two sets
    00091         * <tt>s1</tt> and <tt>s2</tt>, as required by the general
    00092         * contract of {@link coherence::lang::Object::hashCode()
    00093         * Object::hashCode()}.
    00094         *
    00095         * @return the hash code value for this set.
    00096         */
    00097         using Object::hashCode;
    00098     };
    00099
    00100 COH_CLOSE_NAMESPACE2
    00101
    00102 #endif // COH_SET_HPP

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