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

E26041-01

coherence/util/TreeSet.hpp

00001 /*
00002 * TreeSet.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_TREE_SET_HPP
00017 #define COH_TREE_SET_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/Comparator.hpp"
00022 #include "coherence/util/MappedSet.hpp"
00023 #include "coherence/util/SortedSet.hpp"
00024 #include "coherence/util/TreeMap.hpp"
00025 
00026 COH_OPEN_NAMESPACE2(coherence,util)
00027 
00028 /**
00029 * A TreeSet implementation based on a TreeMap. The elements are ordered using
00030 * their natural ordering, or by a Comparator provided at set creation time,
00031 * depending on which constructor is used.
00032 *
00033 * @author hr  2011.09.07
00034 *
00035 * @see SortedSet
00036 * @see TreeMap
00037 *
00038 * @since Coherence 12.1.2
00039 */
00040 class COH_EXPORT TreeSet
00041     : public cloneable_spec<TreeSet,
00042           extends<MappedSet>,
00043           implements<SortedSet> >
00044     {
00045     friend class factory<TreeSet>;
00046 
00047     // ----- constructors ---------------------------------------------------
00048 
00049     protected:
00050         /**
00051         * Return a new TreeSet that will sort it's elements using their
00052         * natural ordering.
00053         */
00054         TreeSet();
00055 
00056         /**
00057         * Return a new TreeSet that will sort it's elements using the
00058         * supplied Comparator.
00059         *
00060         * @param vComparator  the Comparator used to sort elements
00061         */
00062         TreeSet(Comparator::View vComparator);
00063 
00064         /**
00065         * Return a TreeSet backed by the given SortedMap.
00066         *
00067         * @param hMap  the delegate SortedMap
00068         */
00069         TreeSet(SortedMap::Handle hMap);
00070 
00071         /**
00072         * Return a TreeSet backed by the given SortedMap.
00073         *
00074         * @param vMap  the delegate SortedMap
00075         */
00076         TreeSet(SortedMap::View vMap);
00077 
00078         /**
00079         * Copy constructor.
00080         */
00081         TreeSet(const TreeSet& that);
00082 
00083     // ----- SortedSet interface --------------------------------------------
00084 
00085     public:
00086         /**
00087         * {@inheritDoc}
00088         */
00089         virtual Comparator::View comparator() const;
00090 
00091         /**
00092         * {@inheritDoc}
00093         */
00094         virtual SortedSet::Handle subSet(Object::View vFromElement,
00095                         Object::View vToElement);
00096 
00097         /**
00098         * {@inheritDoc}
00099         */
00100         virtual SortedSet::View subSet(Object::View vFromElement,
00101                         Object::View vToElement) const;
00102 
00103         /**
00104         * {@inheritDoc}
00105         */
00106         virtual SortedSet::Handle headSet(Object::View vToElement);
00107 
00108         /**
00109         * {@inheritDoc}
00110         */
00111         virtual SortedSet::View headSet(Object::View vToElement) const;
00112 
00113         /**
00114         * {@inheritDoc}
00115         */
00116         virtual SortedSet::Handle tailSet(Object::View vFromElement);
00117 
00118         /**
00119         * {@inheritDoc}
00120         */
00121         virtual SortedSet::View tailSet(Object::View vFromElement) const;
00122 
00123         /**
00124         * {@inheritDoc}
00125         */
00126         virtual Object::View first() const;
00127 
00128         /**
00129         * {@inheritDoc}
00130         */
00131         virtual Object::View last() const;
00132 
00133     // ----- helpers --------------------------------------------------------
00134 
00135     protected:
00136         /**
00137         * Throws an exception iff the internal map is inaccessible.
00138         *
00139         * @throws IllegalStateException iff the internal map is inaccessible
00140         */
00141         virtual void ensureMap();
00142 
00143         /**
00144         * Return the delegate SortedMap.
00145         *
00146         * @return the delegate SortedMap
00147         */
00148         virtual SortedMap::Handle getSortedMap();
00149 
00150         /**
00151         * Return the delegate SortedMap.
00152         *
00153         * @return the delegate SortedMap
00154         */
00155         virtual SortedMap::View getSortedMap() const;
00156     };
00157 
00158 COH_CLOSE_NAMESPACE2
00159 
00160 #endif // COH_TREE_SET_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.