Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


XalanSet.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #if !defined(XALANSET_HEADER_GUARD_1357924680)
20 #define XALANSET_HEADER_GUARD_1357924680
21 
22 
23 
24 // Base include file. Must be first.
27 
28 
29 
31 
32 
33 
34 XALAN_CPP_NAMESPACE_BEGIN
35 
36 
37 
38 template <class Value, class MapIterator>
40 {
41  typedef Value value_type;
42 
43  typedef Value& reference;
44  typedef Value* pointer;
45 
46  typedef ptrdiff_t difference_type;
47  typedef XALAN_STD_QUALIFIER bidirectional_iterator_tag iterator_category;
48 
49  XalanSetIterator(const MapIterator& iter) :
50  m_mapIterator(iter)
51  {
52  }
53 
54  reference operator*() const
55  {
56  return m_mapIterator->first;
57  };
58 
59  bool operator==(const XalanSetIterator& theRhs) const
60  {
61  return theRhs.m_mapIterator == m_mapIterator;
62  }
63 
64  bool operator!=(const XalanSetIterator& theRhs) const
65  {
66  return !(theRhs == *this);
67  }
68 
70  {
71  ++m_mapIterator;
72 
73  return *this;
74  }
75 
77  {
79 
80  ++(*this);
81 
82  return orig;
83  }
84 
85 protected:
86 
87  MapIterator m_mapIterator;
88 };
89 
90 
91 /**
92  * Xalan set implementation.
93  *
94  * Set relies on the XalanMap hashtable. Users must ensure the right key
95  * traits specialization is aviable to define the proper hash functor.
96  */
97 template <class Value>
98 class XalanSet
99 {
100 public:
101 
102  typedef Value value_type;
103 
104  typedef size_t size_type;
105 
107 
110 
111  XalanSet(MemoryManager& theMemoryManager) :
112  m_map(theMemoryManager)
113  {
114  }
115 
117  const XalanSet& other,
118  MemoryManager& theMemoryManager) :
119  m_map(other.m_map, theMemoryManager)
120  {
121  }
122 
123  MemoryManager&
125  {
126  return m_map.getMemoryManager();
127  }
128 
129  const_iterator
130  begin() const
131  {
132  return m_map.begin();
133  }
134 
135  const_iterator
136  end() const
137  {
138  return m_map.end();
139  }
140 
141  size_type
142  size() const {
143  return m_map.size();
144  }
145 
146  size_type
147  count(const value_type& value) const
148  {
149  return find(value) != end() ? 1 : 0;
150  }
151 
152  const_iterator
153  find(const value_type& value) const
154  {
155  return m_map.find(value);
156  }
157 
158  void
159  insert(const value_type& value)
160  {
161  m_map.insert(value, true);
162  }
163 
164  size_type
165  erase(const value_type& value)
166  {
167  return m_map.erase(value);
168  }
169 
170  void
172  {
173  m_map.clear();
174  }
175 
176 private:
177 
178  SetMapType m_map;
179 };
180 
181 
182 
183 XALAN_CPP_NAMESPACE_END
184 
185 #endif // XALANSET_HEADER_GUARD_1357924680
Value & reference
Definition: XalanSet.hpp:43
void insert(const value_type &value)
Definition: XalanSet.hpp:159
const_iterator find(const value_type &value) const
Definition: XalanSet.hpp:153
void clear()
Definition: XalanSet.hpp:171
XalanSetIterator operator++()
Definition: XalanSet.hpp:69
MemoryManager & getMemoryManager()
Definition: XalanSet.hpp:124
XalanMap< value_type, bool > SetMapType
Definition: XalanSet.hpp:106
bool operator!=(const XalanSetIterator &theRhs) const
Definition: XalanSet.hpp:64
XalanSet(MemoryManager &theMemoryManager)
Definition: XalanSet.hpp:111
MapIterator m_mapIterator
Definition: XalanSet.hpp:87
size_t size_type
Definition: XalanSet.hpp:104
XalanSetIterator operator++(int)
Definition: XalanSet.hpp:76
XalanSetIterator(const MapIterator &iter)
Definition: XalanSet.hpp:49
bool operator==(const XalanSetIterator &theRhs) const
Definition: XalanSet.hpp:59
XalanSetIterator< const value_type, typename SetMapType::const_iterator > const_iterator
Definition: XalanSet.hpp:109
reference operator*() const
Definition: XalanSet.hpp:54
size_type count(const value_type &value) const
Definition: XalanSet.hpp:147
const_iterator end() const
Definition: XalanSet.hpp:136
size_type size() const
Definition: XalanSet.hpp:142
const_iterator begin() const
Definition: XalanSet.hpp:130
ptrdiff_t difference_type
Definition: XalanSet.hpp:46
Value value_type
Definition: XalanSet.hpp:102
Xalan set implementation.
Definition: XalanSet.hpp:98
size_type erase(const value_type &value)
Definition: XalanSet.hpp:165
XalanSetIterator< value_type, typename SetMapType::iterator > iterator
Definition: XalanSet.hpp:108
XALAN_STD_QUALIFIER bidirectional_iterator_tag iterator_category
Definition: XalanSet.hpp:47
XalanSet(const XalanSet &other, MemoryManager &theMemoryManager)
Definition: XalanSet.hpp:116
Value * pointer
Definition: XalanSet.hpp:44

Interpreting class diagrams

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

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

Apache Logo