Oracle Coherence for C++ API
Release 3.7.0.0

E18684-01

coherence/util/AbstractCollection.hpp

00001 /*
00002 * AbstractCollection.hpp
00003 *
00004 * Copyright (c) 2000, 2011, 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_ABSTRACT_COLLECTION_HPP
00017 #define COH_ABSTRACT_COLLECTION_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/Collection.hpp"
00022 #include "coherence/util/Iterator.hpp"
00023 
00024 #include <ostream>
00025 
00026 COH_OPEN_NAMESPACE2(coherence,util)
00027 
00028 
00029 /**
00030 * This class provides a skeletal implementation of the <tt>Collection</tt>
00031 * interface, to minimize the effort required to implement this interface.
00032 *
00033 * To implement an unmodifiable collection, the programmer needs only to
00034 * extend this class and provide implementations for the <tt>size</tt> and
00035 * <tt>iterator</tt> methods.
00036 *
00037 * To implement a modifiable collection, the programmer must additionally
00038 * override this class's <tt>add</tt>, <tt>remove</tt>, <tt>removeAll</tt>,
00039 * <tt>retainAll</tt> and <tt>clear</tt> methods
00040 * (which otherwise throw an <tt>UnsupportedOperationException</tt>).
00041 *
00042 * The programmer should generally provide a void (no argument) and
00043 * <tt>Collection</tt> constructor, as per the recommendation in the
00044 * <tt>Collection</tt> interface specification.
00045 *
00046 * @see Collection
00047 */
00048 class COH_EXPORT AbstractCollection
00049     : public abstract_spec<AbstractCollection,
00050         extends<Object>,
00051         implements<Collection> >
00052     {
00053     // ----- Collection interface --------------------------------------------
00054 
00055     public:
00056         // Query Operations
00057 
00058         /**
00059         * {@inheritDoc}
00060         */
00061         virtual size32_t size() const = 0;
00062 
00063         /**
00064         * {@inheritDoc}
00065         */
00066         virtual bool isEmpty() const;
00067 
00068         /**
00069         * {@inheritDoc}
00070         */
00071         virtual bool contains(Object::View v) const;
00072 
00073         /**
00074         * {@inheritDoc}
00075         */
00076         virtual ObjectArray::Handle toArray(
00077                 ObjectArray::Handle hao = NULL) const;
00078 
00079         /**
00080         * {@inheritDoc}
00081         *
00082         * This implementation iterates over the specified collection,
00083         * checking each element returned by the iterator in turn to see if
00084         * it's contained in this collection. If all elements are so
00085         * contained <tt>true</tt> is returned, otherwise <tt>false</tt>.
00086         */
00087         virtual bool containsAll(Collection::View vc) const;
00088 
00089         /**
00090         * {@inheritDoc}
00091         *
00092         * This implementation will throw a
00093         * coherence::lang::UnsupportedOperationException
00094         */
00095         virtual bool add(Object::Holder oh);
00096 
00097         /**
00098         * {@inheritDoc}
00099         *
00100         * This implementation will throw a
00101         * coherence::lang::UnsupportedOperationException unless #add() is
00102         * overridden (assuming the specified collection is non-empty).
00103         */
00104         virtual bool addAll(Collection::View vc);
00105 
00106         /**
00107         * {@inheritDoc}
00108         *
00109         * This implementation will throw a
00110         * coherence::lang::UnsupportedOperationException unless #add() is
00111         * overridden (assuming the specified collection is non-empty).
00112         */
00113         virtual bool remove(Object::View v);
00114 
00115         /**
00116         * {@inheritDoc}
00117         *
00118         * This implementation will throw a
00119         * coherence::lang::UnsupportedOperationException} unless #remove() is
00120         * overridden (assuming the specified collection is non-empty).
00121         */
00122         virtual bool removeAll(Collection::View vc);
00123 
00124         /**
00125         * {@inheritDoc}
00126         *
00127         * This implementation will throw a
00128         * coherence::lang::UnsupportedOperationException unless #remove() is
00129         * overridden (assuming there are items to be removed by the
00130         * operation).
00131         */
00132         virtual bool retainAll(Collection::View vc);
00133 
00134         /**
00135         * {@inheritDoc}
00136         *
00137         * This implementation will throw a
00138         * coherence::lang::UnsupportedOperationException.
00139         */
00140         virtual void clear();
00141 
00142 
00143     // ----- Object interface -----------------------------------------------
00144 
00145     public:
00146         /**
00147         * {@inheritDoc}
00148         */
00149         virtual void toStream(std::ostream &out) const;
00150     };
00151 
00152 COH_CLOSE_NAMESPACE2
00153 
00154 #endif // COH_ABSTRACT_COLLECTION_HPP
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.