Oracle Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.2)

E26041-01

coherence/util/SubList.hpp

00001 /*
00002 * SubList.hpp
00003 *
00004 * Copyright (c) 2000, 2013, 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_SUB_LIST_HPP
00017 #define COH_SUB_LIST_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/AbstractList.hpp"
00022 #include "coherence/util/List.hpp"
00023 
00024 COH_OPEN_NAMESPACE2(coherence,util)
00025 
00026 
00027 /**
00028 * SubList delegates all operations to it's full list while providing a
00029 * partial view of the list.
00030 *
00031 * @author nsa 2008.02.08
00032 */
00033 class COH_EXPORT SubList
00034     : public abstract_spec<SubList,
00035         extends<AbstractList> >
00036     {
00037     // ----- constructor ----------------------------------------------------
00038 
00039     public:
00040         /**
00041         * @internal
00042         */
00043         SubList(size32_t fromIndex, size32_t toIndex, List::Holder ohList);
00044 
00045     private:
00046         /**
00047         * Blocked copy constructor
00048         */
00049         SubList(const SubList&);
00050 
00051 
00052     // ----- List interface -------------------------------------------------
00053 
00054     public:
00055         /**
00056         * {@inheritDoc}
00057         */
00058         virtual bool add(size32_t i, Object::Holder oh);
00059 
00060         /**
00061         * {@inheritDoc}
00062         */
00063         virtual bool addAll(size32_t i, Collection::View vc);
00064 
00065         /**
00066         * {@inheritDoc}
00067         */
00068         virtual Object::Holder get(size32_t i) const;
00069 
00070         /**
00071         * {@inheritDoc}
00072         */
00073         using List::get;
00074 
00075         /**
00076         * {@inheritDoc}
00077         */
00078         virtual size32_t indexOf(Object::View v) const;
00079 
00080         /**
00081         * {@inheritDoc}
00082         */
00083         virtual size32_t lastIndexOf(Object::View v) const;
00084 
00085         /**
00086         * {@inheritDoc}
00087         */
00088         virtual ListIterator::Handle listIterator(size32_t index = 0) const;
00089 
00090         /**
00091         * {@inheritDoc}
00092         */
00093         virtual ListMuterator::Handle listIterator(size32_t index = 0);
00094 
00095         /**
00096         * {@inheritDoc}
00097         */
00098         virtual Object::Holder remove(size32_t idx);
00099 
00100         /**
00101         * {@inheritDoc}
00102         */
00103         virtual Object::Holder set(size32_t idx, Object::Holder oh);
00104 
00105 
00106     // ----- Collection interface -------------------------------------------
00107 
00108     public:
00109         /**
00110         * {@inheritDoc}
00111         */
00112         virtual size32_t size() const;
00113 
00114         /**
00115         * {@inheritDoc}
00116         */
00117         virtual Iterator::Handle iterator() const;
00118 
00119         /**
00120         * {@inheritDoc}
00121         */
00122         virtual Muterator::Handle iterator();
00123 
00124         /**
00125         * {@inheritDoc}
00126         */
00127         virtual bool add(Object::Holder oh);
00128 
00129         /**
00130         * {@inheritDoc}
00131         */
00132         virtual bool addAll(Collection::View vc);
00133 
00134         /**
00135         * {@inheritDoc}
00136         */
00137         virtual bool remove(Object::View v);
00138 
00139 
00140     // ----- helper methods -------------------------------------------------
00141 
00142     protected:
00143         /**
00144         * Validate that the supplied index is in the appropriate range
00145         * for this SubList.
00146         *
00147         * @param i  the index to test against the SubList's boundaries
00148         *
00149         * @throws coherence::lang::IndexOutOfBoundsException iff the
00150         * supplied index is outside the range of this SubList.
00151         */
00152         void assertIndex(size32_t i) const;
00153 
00154         /**
00155         * Return the to delegate to.
00156         *
00157         * @return the list to delegate to
00158         */
00159         virtual List::Handle getDelegate();
00160 
00161         /**
00162         * Return the to delegate to.
00163         *
00164         * @return the list to delegate to
00165         */
00166         virtual List::View getDelegate() const;
00167 
00168     // ----- data members ---------------------------------------------------
00169 
00170     protected:
00171         /**
00172         * The underlying list this is a sublist of
00173         */
00174         FinalHolder<List> f_ohList;
00175 
00176         /**
00177         * The offset this list is based on from the underlying list.
00178         */
00179         size32_t m_iOffset;
00180 
00181         /**
00182         * The size of this sublist.
00183         */
00184         size32_t m_iSize;
00185     };
00186 
00187 COH_CLOSE_NAMESPACE2
00188 
00189 #endif // COH_SUB_LIST_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.