Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XalanSet.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00020 
00021 #if !defined(XALANSET_HEADER_GUARD_1357924680)
00022 #define XALANSET_HEADER_GUARD_1357924680
00023 
00024 
00025 
00026 // Base include file.  Must be first.
00027 #include <xalanc/Include/PlatformDefinitions.hpp>
00028 #include <xalanc/Include/XalanMap.hpp>
00029 
00030 
00031 
00032 #include <xalanc/Include/XalanMemoryManagement.hpp>
00033 
00034 
00035 
00036 XALAN_CPP_NAMESPACE_BEGIN
00037 
00038 
00039 
00040 template <class Value, class MapIterator>
00041 struct XalanSetIterator
00042 {
00043     typedef Value  value_type;
00044 
00045     typedef Value& reference;
00046     typedef Value* pointer;
00047 
00048     XalanSetIterator(const MapIterator & iter) :
00049         m_mapIterator(iter)
00050     {
00051     }
00052 
00053     reference operator*() const
00054     {
00055         return m_mapIterator->first;
00056     };
00057 
00058     bool operator==(const XalanSetIterator& theRhs) const
00059     {
00060         return theRhs.m_mapIterator == m_mapIterator;
00061     }
00062 
00063     bool operator!=(const XalanSetIterator& theRhs) const
00064     {
00065         return !(theRhs == *this);
00066     }
00067 
00068     XalanSetIterator operator++()
00069     {
00070         ++m_mapIterator;
00071         return *this;
00072     }
00073 
00074     XalanSetIterator operator++(int)
00075     {
00076         XalanSetIterator orig(m_mapIterator);
00077         ++(*this);
00078         return orig;
00079     }
00080 
00081 protected:
00082     MapIterator m_mapIterator;
00083 };
00084 
00085 
00092 template <class Value>
00093 class XalanSet
00094 {
00095 public:
00096 
00097     typedef Value   value_type;
00098 
00099     typedef size_t  size_type;
00100 
00101     typedef XalanMap<value_type, bool>  SetMapType;
00102 
00103     typedef XalanSetIterator<value_type, typename SetMapType::iterator>             iterator;
00104     typedef XalanSetIterator<const value_type, typename SetMapType::const_iterator> const_iterator;
00105 
00106     XalanSet(MemoryManagerType& theMemoryManager) :
00107         m_map(theMemoryManager)
00108     {
00109     }
00110 
00111     XalanSet(const XalanSet&    other,
00112              MemoryManagerType& theMemoryManager) :
00113         m_map(other.m_map, theMemoryManager)
00114     {
00115     }
00116 
00117     MemoryManagerType&
00118     getMemoryManager()
00119     {
00120         return m_map.getMemoryManager();
00121     }
00122 
00123     const_iterator begin() const
00124     {
00125         return m_map.begin();
00126     }
00127 
00128     const_iterator end() const
00129     {
00130         return m_map.end();
00131     }
00132 
00133     size_type size() const {
00134         return m_map.size();
00135     }
00136 
00137     size_type count(const value_type & value) const 
00138     {
00139         if (find(value) != end())
00140         {
00141             return 1;
00142         }
00143         else
00144         {
00145             return 0;
00146         }
00147     }
00148 
00149     const_iterator find(const value_type& value) const
00150     {
00151         return m_map.find(value);
00152     }
00153 
00154     void insert(const value_type& value)
00155     {
00156     typedef typename SetMapType::value_type MapValueType;
00157         m_map.insert(value, true);
00158     }
00159 
00160     size_type erase(const value_type& value)
00161     {
00162         return m_map.erase(value);
00163     }
00164 
00165     void clear()
00166     {
00167         m_map.clear();
00168     }
00169 
00170     SetMapType m_map;
00171 };
00172 
00173 
00174 
00175 XALAN_CPP_NAMESPACE_END
00176 
00177 #endif  // XALANSET_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo