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