| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "wtf/PassTraits.h" | 36 #include "wtf/PassTraits.h" |
| 37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
| 38 #include <iterator> | 38 #include <iterator> |
| 39 | 39 |
| 40 namespace WTF { | 40 namespace WTF { |
| 41 | 41 |
| 42 template <typename T, size_t inlineCapacity, typename Allocator> class DequeIter
atorBase; | 42 template <typename T, size_t inlineCapacity, typename Allocator> class DequeIter
atorBase; |
| 43 template <typename T, size_t inlineCapacity, typename Allocator> class DequeIter
ator; | 43 template <typename T, size_t inlineCapacity, typename Allocator> class DequeIter
ator; |
| 44 template <typename T, size_t inlineCapacity, typename Allocator> class DequeCons
tIterator; | 44 template <typename T, size_t inlineCapacity, typename Allocator> class DequeCons
tIterator; |
| 45 | 45 |
| 46 template <typename T, size_t inlineCapacity = 0, typename Allocator = DefaultAll
ocator> | 46 template <typename T, size_t inlineCapacity = 0, typename Allocator = PartitionA
llocator> |
| 47 class Deque : public ConditionalDestructor<Deque<T, INLINE_CAPACITY, Allocator>,
(INLINE_CAPACITY == 0) && Allocator::isGarbageCollected> { | 47 class Deque : public ConditionalDestructor<Deque<T, INLINE_CAPACITY, Allocator>,
(INLINE_CAPACITY == 0) && Allocator::isGarbageCollected> { |
| 48 WTF_USE_ALLOCATOR(Deque, Allocator); | 48 WTF_USE_ALLOCATOR(Deque, Allocator); |
| 49 public: | 49 public: |
| 50 typedef DequeIterator<T, inlineCapacity, Allocator> iterator; | 50 typedef DequeIterator<T, inlineCapacity, Allocator> iterator; |
| 51 typedef DequeConstIterator<T, inlineCapacity, Allocator> const_iterator; | 51 typedef DequeConstIterator<T, inlineCapacity, Allocator> const_iterator; |
| 52 typedef std::reverse_iterator<iterator> reverse_iterator; | 52 typedef std::reverse_iterator<iterator> reverse_iterator; |
| 53 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 53 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 54 typedef PassTraits<T> Pass; | 54 typedef PassTraits<T> Pass; |
| 55 typedef typename PassTraits<T>::PassType PassType; | 55 typedef typename PassTraits<T>::PassType PassType; |
| 56 | 56 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 bool isEqual(const DequeIteratorBase&) const; | 152 bool isEqual(const DequeIteratorBase&) const; |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 Deque<T, inlineCapacity, Allocator>* m_deque; | 155 Deque<T, inlineCapacity, Allocator>* m_deque; |
| 156 unsigned m_index; | 156 unsigned m_index; |
| 157 | 157 |
| 158 friend class Deque<T, inlineCapacity, Allocator>; | 158 friend class Deque<T, inlineCapacity, Allocator>; |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 template <typename T, size_t inlineCapacity = 0, typename Allocator = DefaultAll
ocator> | 161 template <typename T, size_t inlineCapacity = 0, typename Allocator = PartitionA
llocator> |
| 162 class DequeIterator : public DequeIteratorBase<T, inlineCapacity, Allocator> { | 162 class DequeIterator : public DequeIteratorBase<T, inlineCapacity, Allocator> { |
| 163 private: | 163 private: |
| 164 typedef DequeIteratorBase<T, inlineCapacity, Allocator> Base; | 164 typedef DequeIteratorBase<T, inlineCapacity, Allocator> Base; |
| 165 typedef DequeIterator<T, inlineCapacity, Allocator> Iterator; | 165 typedef DequeIterator<T, inlineCapacity, Allocator> Iterator; |
| 166 | 166 |
| 167 public: | 167 public: |
| 168 typedef ptrdiff_t difference_type; | 168 typedef ptrdiff_t difference_type; |
| 169 typedef T value_type; | 169 typedef T value_type; |
| 170 typedef T* pointer; | 170 typedef T* pointer; |
| 171 typedef T& reference; | 171 typedef T& reference; |
| 172 typedef std::bidirectional_iterator_tag iterator_category; | 172 typedef std::bidirectional_iterator_tag iterator_category; |
| 173 | 173 |
| 174 DequeIterator(Deque<T, inlineCapacity, Allocator>* deque, size_t index) : Ba
se(deque, index) {} | 174 DequeIterator(Deque<T, inlineCapacity, Allocator>* deque, size_t index) : Ba
se(deque, index) {} |
| 175 | 175 |
| 176 DequeIterator(const Iterator& other) : Base(other) {} | 176 DequeIterator(const Iterator& other) : Base(other) {} |
| 177 DequeIterator& operator=(const Iterator& other) { Base::assign(other); retur
n *this; } | 177 DequeIterator& operator=(const Iterator& other) { Base::assign(other); retur
n *this; } |
| 178 | 178 |
| 179 T& operator*() const { return *Base::after(); } | 179 T& operator*() const { return *Base::after(); } |
| 180 T* operator->() const { return Base::after(); } | 180 T* operator->() const { return Base::after(); } |
| 181 | 181 |
| 182 bool operator==(const Iterator& other) const { return Base::isEqual(other);
} | 182 bool operator==(const Iterator& other) const { return Base::isEqual(other);
} |
| 183 bool operator!=(const Iterator& other) const { return !Base::isEqual(other);
} | 183 bool operator!=(const Iterator& other) const { return !Base::isEqual(other);
} |
| 184 | 184 |
| 185 Iterator& operator++() { Base::increment(); return *this; } | 185 Iterator& operator++() { Base::increment(); return *this; } |
| 186 // postfix ++ intentionally omitted | 186 // postfix ++ intentionally omitted |
| 187 Iterator& operator--() { Base::decrement(); return *this; } | 187 Iterator& operator--() { Base::decrement(); return *this; } |
| 188 // postfix -- intentionally omitted | 188 // postfix -- intentionally omitted |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 template <typename T, size_t inlineCapacity = 0, typename Allocator = DefaultAll
ocator> | 191 template <typename T, size_t inlineCapacity = 0, typename Allocator = PartitionA
llocator> |
| 192 class DequeConstIterator : public DequeIteratorBase<T, inlineCapacity, Allocator
> { | 192 class DequeConstIterator : public DequeIteratorBase<T, inlineCapacity, Allocator
> { |
| 193 private: | 193 private: |
| 194 typedef DequeIteratorBase<T, inlineCapacity, Allocator> Base; | 194 typedef DequeIteratorBase<T, inlineCapacity, Allocator> Base; |
| 195 typedef DequeConstIterator<T, inlineCapacity, Allocator> Iterator; | 195 typedef DequeConstIterator<T, inlineCapacity, Allocator> Iterator; |
| 196 typedef DequeIterator<T, inlineCapacity, Allocator> NonConstIterator; | 196 typedef DequeIterator<T, inlineCapacity, Allocator> NonConstIterator; |
| 197 | 197 |
| 198 public: | 198 public: |
| 199 typedef ptrdiff_t difference_type; | 199 typedef ptrdiff_t difference_type; |
| 200 typedef T value_type; | 200 typedef T value_type; |
| 201 typedef const T* pointer; | 201 typedef const T* pointer; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 struct NeedsTracing<Deque<T, N>> { | 574 struct NeedsTracing<Deque<T, N>> { |
| 575 static const bool value = false; | 575 static const bool value = false; |
| 576 }; | 576 }; |
| 577 #endif | 577 #endif |
| 578 | 578 |
| 579 } // namespace WTF | 579 } // namespace WTF |
| 580 | 580 |
| 581 using WTF::Deque; | 581 using WTF::Deque; |
| 582 | 582 |
| 583 #endif // WTF_Deque_h | 583 #endif // WTF_Deque_h |
| OLD | NEW |