Xalan-C++ API Reference 1.12.0
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
34namespace XALAN_CPP_NAMESPACE {
35
36
37
38template <class Value, class MapIterator>
40{
42
43 typedef Value& reference;
44 typedef Value* pointer;
45
47 typedef std::bidirectional_iterator_tag iterator_category;
48
50 m_mapIterator(iter)
51 {
52 }
53
55 {
56 return m_mapIterator->first;
57 };
58
60 {
61 return theRhs.m_mapIterator == m_mapIterator;
62 }
63
65 {
66 return !(theRhs == *this);
67 }
68
70 {
71 ++m_mapIterator;
72
73 return *this;
74 }
75
77 {
78 XalanSetIterator orig(m_mapIterator);
79
80 ++(*this);
81
82 return orig;
83 }
84
85protected:
86
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 */
97template <class Value>
99{
100public:
101
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
142 size() const {
143 return m_map.size();
144 }
145
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
165 erase(const value_type& value)
166 {
167 return m_map.erase(value);
168 }
169
170 void
172 {
173 m_map.clear();
174 }
175
176private:
177
178 SetMapType m_map;
179};
180
181
182
183}
184
185#endif // XALANSET_HEADER_GUARD_1357924680
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Xalan set implementation.
Definition XalanSet.hpp:99
size_type count(const value_type &value) const
Definition XalanSet.hpp:147
const_iterator begin() const
Definition XalanSet.hpp:130
MemoryManager & getMemoryManager()
Definition XalanSet.hpp:124
XalanMap< value_type, bool > SetMapType
Definition XalanSet.hpp:106
XalanSetIterator< const value_type, typename SetMapType::const_iterator > const_iterator
Definition XalanSet.hpp:109
size_type erase(const value_type &value)
Definition XalanSet.hpp:165
XalanSet(MemoryManager &theMemoryManager)
Definition XalanSet.hpp:111
const_iterator find(const value_type &value) const
Definition XalanSet.hpp:153
size_type size() const
Definition XalanSet.hpp:142
const_iterator end() const
Definition XalanSet.hpp:136
void insert(const value_type &value)
Definition XalanSet.hpp:159
XalanSet(const XalanSet &other, MemoryManager &theMemoryManager)
Definition XalanSet.hpp:116
XalanSetIterator< value_type, typename SetMapType::iterator > iterator
Definition XalanSet.hpp:108
size_t size_type
Definition XalanMap.hpp:46
bool operator==(const XalanSetIterator &theRhs) const
Definition XalanSet.hpp:59
MapIterator m_mapIterator
Definition XalanSet.hpp:87
XalanSetIterator operator++(int)
Definition XalanSet.hpp:76
std::bidirectional_iterator_tag iterator_category
Definition XalanSet.hpp:47
reference operator*() const
Definition XalanSet.hpp:54
XalanSetIterator(const MapIterator &iter)
Definition XalanSet.hpp:49
XalanSetIterator operator++()
Definition XalanSet.hpp:69
bool operator!=(const XalanSetIterator &theRhs) const
Definition XalanSet.hpp:64