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

- Main Page
- Namespaces
- Classes
- Files

# coherence/util/FilterMuterator.hpp

    00001 /*
    00002 * FilterMuterator.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_FILTER_MUTERATOR_HPP
    00017 #define COH_FILTER_MUTERATOR_HPP
    00018
    00019 #include "coherence/lang.ns"
    00020 #include "coherence/util/Filter.hpp"
    00021 #include "coherence/util/Muterator.hpp"
    00022
    00023 COH_OPEN_NAMESPACE2(coherence,util)
    00024
    00025
    00026 /**
    00027 * Provides a generic implementation of an iterator which can iterate items
    00028 * based on an inclusion test
    00029 *
    00030 * @authore nsa 2008.06.23
    00031 */
    00032
    00033 class COH_EXPORT FilterMuterator
    00034     : public class_spec<FilterMuterator,
    00035         extends<Object>,
    00036         implements<Muterator> >
    00037     {
    00038     friend class factory<FilterMuterator>;
    00039
    00040     // ----- constructor ----------------------------------------------------
    00041
    00042     protected:
    00043         /**
    00044         * Construct a hash map using the specified settings.
    00045         *
    00046         * @param hMuterator  the muterator to a list that should be filtered
    00047         * @param vTest       the test used to filter results
    00048         */
    00049         FilterMuterator(Iterator::Handle hIter, Filter::View vTest);
    00050
    00051
    00052     // ----- Iterator interface ---------------------------------------------
    00053
    00054     public:
    00055         /**
    00056         * Determine if the iteration has another element.
    00057         *
    00058         * @return true if the iterator has another element
    00059         */
    00060         virtual bool hasNext() const;
    00061
    00062         /**
    00063         * Return the next element in the iterated series.
    00064         *
    00065         * @return the next element in the iterated series
    00066         *
    00067         * @throws coherence::lang::NoSuchElementException if iteration has no
    00068         *         more elements
    00069         */
    00070         virtual Object::Holder next();
    00071
    00072
    00073     // ----- Muterator interface --------------------------------------------
    00074
    00075     public:
    00076         /**
    00077         * Remove from the collection associated with this iterator, the last
    00078         * element retruned from the iterator.
    00079         *
    00080         * @throws UnsupportedOperationException if removal is not supported
    00081         */
    00082         virtual void remove();
    00083
    00084
    00085     // ----- data members ---------------------------------------------------
    00086
    00087     protected:
    00088         /**
    00089         * Objects to filter
    00090         */
    00091         mutable FinalHandle<Iterator> m_hIter;
    00092
    00093         /**
    00094         * Test to perform on each item
    00095         */
    00096         FinalView<Filter> m_vTest;
    00097
    00098         /**
    00099         * Is there a next item which passed the test?
    00100         */
    00101         mutable bool m_fNext;
    00102
    00103         /**
    00104         * Is there a previous item which passed the test and can be removed?
    00105         */
    00106         mutable bool m_fPrev;
    00107
    00108         /**
    00109         * The next item which passed the test.
    00110         */
    00111         mutable MemberHolder<Object> m_ohNext;
    00112     };
    00113
    00114 COH_CLOSE_NAMESPACE2
    00115
    00116 #endif //COH_FILTER_MUTERATOR_HPP

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