• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

WTF

  • kjs
  • wtf
HashIterators.h
Go to the documentation of this file.
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef WTF_HashIterators_h
28#define WTF_HashIterators_h
29
30namespace WTF {
31
32 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstKeysIterator;
33 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstValuesIterator;
34 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableKeysIterator;
35 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableValuesIterator;
36
37 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > {
38 private:
39 typedef std::pair<KeyType, MappedType> ValueType;
40 public:
41 typedef HashTableConstKeysIterator<HashTableType, KeyType, MappedType> Keys;
42 typedef HashTableConstValuesIterator<HashTableType, KeyType, MappedType> Values;
43
44 HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {}
45
46 const ValueType* get() const { return (const ValueType*)m_impl.get(); }
47 const ValueType& operator*() const { return *get(); }
48 const ValueType* operator->() const { return get(); }
49
50 HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; }
51 // postfix ++ intentionally omitted
52
53 Keys keys() { return Keys(*this); }
54 Values values() { return Values(*this); }
55
56 typename HashTableType::const_iterator m_impl;
57 };
58
59 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > {
60 private:
61 typedef std::pair<KeyType, MappedType> ValueType;
62 public:
63 typedef HashTableKeysIterator<HashTableType, KeyType, MappedType> Keys;
64 typedef HashTableValuesIterator<HashTableType, KeyType, MappedType> Values;
65
66 HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {}
67
68 ValueType* get() const { return (ValueType*)m_impl.get(); }
69 ValueType& operator*() const { return *get(); }
70 ValueType* operator->() const { return get(); }
71
72 HashTableIteratorAdapter& operator++() { ++m_impl; return *this; }
73 // postfix ++ intentionally omitted
74
75 operator HashTableConstIteratorAdapter<HashTableType, ValueType>() {
76 typename HashTableType::const_iterator i = m_impl;
77 return i;
78 }
79
80 Keys keys() { return Keys(*this); }
81 Values values() { return Values(*this); }
82
83 typename HashTableType::iterator m_impl;
84 };
85
86 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstKeysIterator {
87 private:
88 typedef HashTableConstIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > ConstIterator;
89
90 public:
91 HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {}
92
93 const KeyType* get() const { return &(m_impl.get()->first); }
94 const KeyType& operator*() const { return *get(); }
95 const KeyType* operator->() const { return get(); }
96
97 HashTableConstKeysIterator& operator++() { ++m_impl; return *this; }
98 // postfix ++ intentionally omitted
99
100 ConstIterator m_impl;
101 };
102
103 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstValuesIterator {
104 private:
105 typedef HashTableConstIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > ConstIterator;
106
107 public:
108 HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {}
109
110 const MappedType* get() const { return &(m_impl.get()->second); }
111 const MappedType& operator*() const { return *get(); }
112 const MappedType* operator->() const { return get(); }
113
114 HashTableConstValuesIterator& operator++() { ++m_impl; return *this; }
115 // postfix ++ intentionally omitted
116
117 ConstIterator m_impl;
118 };
119
120 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableKeysIterator {
121 private:
122 typedef HashTableIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > Iterator;
123 typedef HashTableConstIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > ConstIterator;
124
125 public:
126 HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {}
127
128 KeyType* get() const { return &(m_impl.get()->first); }
129 KeyType& operator*() const { return *get(); }
130 KeyType* operator->() const { return get(); }
131
132 HashTableKeysIterator& operator++() { ++m_impl; return *this; }
133 // postfix ++ intentionally omitted
134
135 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>() {
136 ConstIterator i = m_impl;
137 return i;
138 }
139
140 Iterator m_impl;
141 };
142
143 template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableValuesIterator {
144 private:
145 typedef HashTableIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > Iterator;
146 typedef HashTableConstIteratorAdapter<HashTableType, std::pair<KeyType, MappedType> > ConstIterator;
147
148 public:
149 HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {}
150
151 MappedType* get() const { return &(m_impl.get()->second); }
152 MappedType& operator*() const { return *get(); }
153 MappedType* operator->() const { return get(); }
154
155 HashTableValuesIterator& operator++() { ++m_impl; return *this; }
156 // postfix ++ intentionally omitted
157
158 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType>() {
159 ConstIterator i = m_impl;
160 return i;
161 }
162
163 Iterator m_impl;
164 };
165
166 template<typename T, typename U, typename V>
167 inline bool operator==(const HashTableConstKeysIterator<T, U, V>& a, const HashTableConstKeysIterator<T, U, V>& b)
168 {
169 return a.m_impl == b.m_impl;
170 }
171
172 template<typename T, typename U, typename V>
173 inline bool operator!=(const HashTableConstKeysIterator<T, U, V>& a, const HashTableConstKeysIterator<T, U, V>& b)
174 {
175 return a.m_impl != b.m_impl;
176 }
177
178 template<typename T, typename U, typename V>
179 inline bool operator==(const HashTableConstValuesIterator<T, U, V>& a, const HashTableConstValuesIterator<T, U, V>& b)
180 {
181 return a.m_impl == b.m_impl;
182 }
183
184 template<typename T, typename U, typename V>
185 inline bool operator!=(const HashTableConstValuesIterator<T, U, V>& a, const HashTableConstValuesIterator<T, U, V>& b)
186 {
187 return a.m_impl != b.m_impl;
188 }
189
190 template<typename T, typename U, typename V>
191 inline bool operator==(const HashTableKeysIterator<T, U, V>& a, const HashTableKeysIterator<T, U, V>& b)
192 {
193 return a.m_impl == b.m_impl;
194 }
195
196 template<typename T, typename U, typename V>
197 inline bool operator!=(const HashTableKeysIterator<T, U, V>& a, const HashTableKeysIterator<T, U, V>& b)
198 {
199 return a.m_impl != b.m_impl;
200 }
201
202 template<typename T, typename U, typename V>
203 inline bool operator==(const HashTableValuesIterator<T, U, V>& a, const HashTableValuesIterator<T, U, V>& b)
204 {
205 return a.m_impl == b.m_impl;
206 }
207
208 template<typename T, typename U, typename V>
209 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a, const HashTableValuesIterator<T, U, V>& b)
210 {
211 return a.m_impl != b.m_impl;
212 }
213
214
215} // namespace WTF
216
217#endif // WTF_HashIterators_h
WTF
Definition: ASCIICType.h:45
WTF::operator!=
bool operator!=(const HashTableConstKeysIterator< T, U, V > &a, const HashTableConstKeysIterator< T, U, V > &b)
Definition: HashIterators.h:173
WTF::operator==
bool operator==(const HashTableConstKeysIterator< T, U, V > &a, const HashTableConstKeysIterator< T, U, V > &b)
Definition: HashIterators.h:167
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >
Definition: HashIterators.h:37
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::values
Values values()
Definition: HashIterators.h:54
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::operator*
const ValueType & operator*() const
Definition: HashIterators.h:47
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::operator++
HashTableConstIteratorAdapter & operator++()
Definition: HashIterators.h:50
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::Keys
HashTableConstKeysIterator< HashTableType, KeyType, MappedType > Keys
Definition: HashIterators.h:41
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::HashTableConstIteratorAdapter
HashTableConstIteratorAdapter(const typename HashTableType::const_iterator &impl)
Definition: HashIterators.h:44
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::m_impl
HashTableType::const_iterator m_impl
Definition: HashIterators.h:56
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::keys
Keys keys()
Definition: HashIterators.h:53
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::get
const ValueType * get() const
Definition: HashIterators.h:46
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::operator->
const ValueType * operator->() const
Definition: HashIterators.h:48
WTF::HashTableConstIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::Values
HashTableConstValuesIterator< HashTableType, KeyType, MappedType > Values
Definition: HashIterators.h:42
WTF::HashTableConstIteratorAdapter
Definition: HashTable.h:1081
WTF::HashTableConstIteratorAdapter::get
const ValueType * get() const
Definition: HashTable.h:1084
WTF::HashTableConstIteratorAdapter::m_impl
HashTableType::const_iterator m_impl
Definition: HashTable.h:1091
WTF::HashTableConstKeysIterator
Definition: HashIterators.h:86
WTF::HashTableConstKeysIterator::operator*
const KeyType & operator*() const
Definition: HashIterators.h:94
WTF::HashTableConstKeysIterator::operator++
HashTableConstKeysIterator & operator++()
Definition: HashIterators.h:97
WTF::HashTableConstKeysIterator::get
const KeyType * get() const
Definition: HashIterators.h:93
WTF::HashTableConstKeysIterator::m_impl
ConstIterator m_impl
Definition: HashIterators.h:100
WTF::HashTableConstKeysIterator::HashTableConstKeysIterator
HashTableConstKeysIterator(const ConstIterator &impl)
Definition: HashIterators.h:91
WTF::HashTableConstKeysIterator::operator->
const KeyType * operator->() const
Definition: HashIterators.h:95
WTF::HashTableConstValuesIterator
Definition: HashIterators.h:103
WTF::HashTableConstValuesIterator::m_impl
ConstIterator m_impl
Definition: HashIterators.h:117
WTF::HashTableConstValuesIterator::get
const MappedType * get() const
Definition: HashIterators.h:110
WTF::HashTableConstValuesIterator::HashTableConstValuesIterator
HashTableConstValuesIterator(const ConstIterator &impl)
Definition: HashIterators.h:108
WTF::HashTableConstValuesIterator::operator*
const MappedType & operator*() const
Definition: HashIterators.h:111
WTF::HashTableConstValuesIterator::operator->
const MappedType * operator->() const
Definition: HashIterators.h:112
WTF::HashTableConstValuesIterator::operator++
HashTableConstValuesIterator & operator++()
Definition: HashIterators.h:114
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >
Definition: HashIterators.h:59
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::Values
HashTableValuesIterator< HashTableType, KeyType, MappedType > Values
Definition: HashIterators.h:64
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::Keys
HashTableKeysIterator< HashTableType, KeyType, MappedType > Keys
Definition: HashIterators.h:63
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::operator*
ValueType & operator*() const
Definition: HashIterators.h:69
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::m_impl
HashTableType::iterator m_impl
Definition: HashIterators.h:83
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::keys
Keys keys()
Definition: HashIterators.h:80
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::operator->
ValueType * operator->() const
Definition: HashIterators.h:70
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::operator++
HashTableIteratorAdapter & operator++()
Definition: HashIterators.h:72
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::get
ValueType * get() const
Definition: HashIterators.h:68
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::values
Values values()
Definition: HashIterators.h:81
WTF::HashTableIteratorAdapter< HashTableType, std::pair< KeyType, MappedType > >::HashTableIteratorAdapter
HashTableIteratorAdapter(const typename HashTableType::iterator &impl)
Definition: HashIterators.h:66
WTF::HashTableIteratorAdapter
Definition: HashTable.h:1094
WTF::HashTableIteratorAdapter::get
ValueType * get() const
Definition: HashTable.h:1097
WTF::HashTableIteratorAdapter::m_impl
HashTableType::iterator m_impl
Definition: HashTable.h:1109
WTF::HashTableKeysIterator
Definition: HashIterators.h:120
WTF::HashTableKeysIterator::operator++
HashTableKeysIterator & operator++()
Definition: HashIterators.h:132
WTF::HashTableKeysIterator::get
KeyType * get() const
Definition: HashIterators.h:128
WTF::HashTableKeysIterator::operator->
KeyType * operator->() const
Definition: HashIterators.h:130
WTF::HashTableKeysIterator::HashTableKeysIterator
HashTableKeysIterator(const Iterator &impl)
Definition: HashIterators.h:126
WTF::HashTableKeysIterator::m_impl
Iterator m_impl
Definition: HashIterators.h:140
WTF::HashTableKeysIterator::operator*
KeyType & operator*() const
Definition: HashIterators.h:129
WTF::HashTableValuesIterator
Definition: HashIterators.h:143
WTF::HashTableValuesIterator::operator->
MappedType * operator->() const
Definition: HashIterators.h:153
WTF::HashTableValuesIterator::get
MappedType * get() const
Definition: HashIterators.h:151
WTF::HashTableValuesIterator::operator++
HashTableValuesIterator & operator++()
Definition: HashIterators.h:155
WTF::HashTableValuesIterator::HashTableValuesIterator
HashTableValuesIterator(const Iterator &impl)
Definition: HashIterators.h:149
WTF::HashTableValuesIterator::operator*
MappedType & operator*() const
Definition: HashIterators.h:152
WTF::HashTableValuesIterator::m_impl
Iterator m_impl
Definition: HashIterators.h:163
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

WTF

Skip menu "WTF"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal