| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef WTF_HashIterators_h | 26 #ifndef WTF_HashIterators_h |
| 27 #define WTF_HashIterators_h | 27 #define WTF_HashIterators_h |
| 28 | 28 |
| 29 namespace WTF { | 29 namespace WTF { |
| 30 | 30 |
| 31 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstKeysIterator; | 31 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstKeysIterator; |
| 32 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstValuesIterator; | 32 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstValuesIterator; |
| 33 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableKeysIterator; | 33 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableKeysIterator; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 typename HashTableType::iterator m_impl; | 84 typename HashTableType::iterator m_impl; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstKeysIterator { | 87 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstKeysIterator { |
| 88 private: | 88 private: |
| 89 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; | 89 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; |
| 90 | 90 |
| 91 public: | 91 public: |
| 92 HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {} | 92 HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {} |
| 93 | 93 |
| 94 const KeyType* get() const { return &(m_impl.get()->key); } | 94 const KeyType* get() const { return &(m_impl.get()->key); } |
| 95 const KeyType& operator*() const { return *get(); } | 95 const KeyType& operator*() const { return *get(); } |
| 96 const KeyType* operator->() const { return get(); } | 96 const KeyType* operator->() const { return get(); } |
| 97 | 97 |
| 98 HashTableConstKeysIterator& operator++() { ++m_impl; return *this; } | 98 HashTableConstKeysIterator& operator++() { ++m_impl; return *this; } |
| 99 // postfix ++ intentionally omitted | 99 // postfix ++ intentionally omitted |
| 100 | 100 |
| 101 ConstIterator m_impl; | 101 ConstIterator m_impl; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstValuesIterator { | 104 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableConstValuesIterator { |
| 105 private: | 105 private: |
| 106 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; | 106 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; |
| 107 | 107 |
| 108 public: | 108 public: |
| 109 HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {
} | 109 HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {
} |
| 110 | 110 |
| 111 const MappedType* get() const { return &(m_impl.get()->value); } | 111 const MappedType* get() const { return &(m_impl.get()->value); } |
| 112 const MappedType& operator*() const { return *get(); } | 112 const MappedType& operator*() const { return *get(); } |
| 113 const MappedType* operator->() const { return get(); } | 113 const MappedType* operator->() const { return get(); } |
| 114 | 114 |
| 115 HashTableConstValuesIterator& operator++() { ++m_impl; return *this; } | 115 HashTableConstValuesIterator& operator++() { ++m_impl; return *this; } |
| 116 // postfix ++ intentionally omitted | 116 // postfix ++ intentionally omitted |
| 117 | 117 |
| 118 ConstIterator m_impl; | 118 ConstIterator m_impl; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableKeysIterator { | 121 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableKeysIterator { |
| 122 private: | 122 private: |
| 123 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Ma
ppedType> > Iterator; | 123 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Ma
ppedType> > Iterator; |
| 124 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; | 124 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; |
| 125 | 125 |
| 126 public: | 126 public: |
| 127 HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {} | 127 HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {} |
| 128 | 128 |
| 129 KeyType* get() const { return &(m_impl.get()->key); } | 129 KeyType* get() const { return &(m_impl.get()->key); } |
| 130 KeyType& operator*() const { return *get(); } | 130 KeyType& operator*() const { return *get(); } |
| 131 KeyType* operator->() const { return get(); } | 131 KeyType* operator->() const { return get(); } |
| 132 | 132 |
| 133 HashTableKeysIterator& operator++() { ++m_impl; return *this; } | 133 HashTableKeysIterator& operator++() { ++m_impl; return *this; } |
| 134 // postfix ++ intentionally omitted | 134 // postfix ++ intentionally omitted |
| 135 | 135 |
| 136 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>(
) { | 136 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>(
) { |
| 137 ConstIterator i = m_impl; | 137 ConstIterator i = m_impl; |
| 138 return i; | 138 return i; |
| 139 } | 139 } |
| 140 | 140 |
| 141 Iterator m_impl; | 141 Iterator m_impl; |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableValuesIterator { | 144 template<typename HashTableType, typename KeyType, typename MappedType> stru
ct HashTableValuesIterator { |
| 145 private: | 145 private: |
| 146 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Ma
ppedType> > Iterator; | 146 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Ma
ppedType> > Iterator; |
| 147 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; | 147 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyTyp
e, MappedType> > ConstIterator; |
| 148 | 148 |
| 149 public: | 149 public: |
| 150 HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {} | 150 HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {} |
| 151 | 151 |
| 152 MappedType* get() const { return &(m_impl.get()->value); } | 152 MappedType* get() const { return &(m_impl.get()->value); } |
| 153 MappedType& operator*() const { return *get(); } | 153 MappedType& operator*() const { return *get(); } |
| 154 MappedType* operator->() const { return get(); } | 154 MappedType* operator->() const { return get(); } |
| 155 | 155 |
| 156 HashTableValuesIterator& operator++() { ++m_impl; return *this; } | 156 HashTableValuesIterator& operator++() { ++m_impl; return *this; } |
| 157 // postfix ++ intentionally omitted | 157 // postfix ++ intentionally omitted |
| 158 | 158 |
| 159 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType
>() { | 159 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType
>() { |
| 160 ConstIterator i = m_impl; | 160 ConstIterator i = m_impl; |
| 161 return i; | 161 return i; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 template<typename T, typename U, typename V> | 209 template<typename T, typename U, typename V> |
| 210 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a, const
HashTableValuesIterator<T, U, V>& b) | 210 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a, const
HashTableValuesIterator<T, U, V>& b) |
| 211 { | 211 { |
| 212 return a.m_impl != b.m_impl; | 212 return a.m_impl != b.m_impl; |
| 213 } | 213 } |
| 214 | 214 |
| 215 | 215 |
| 216 } // namespace WTF | 216 } // namespace WTF |
| 217 | 217 |
| 218 #endif // WTF_HashIterators_h | 218 #endif // WTF_HashIterators_h |
| OLD | NEW |