| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void removeFirst(); | 105 void removeFirst(); |
| 106 void removeLast(); | 106 void removeLast(); |
| 107 void remove(iterator&); | 107 void remove(iterator&); |
| 108 void remove(const_iterator&); | 108 void remove(const_iterator&); |
| 109 | 109 |
| 110 void clear(); | 110 void clear(); |
| 111 | 111 |
| 112 template<typename Predicate> | 112 template<typename Predicate> |
| 113 iterator findIf(Predicate&); | 113 iterator findIf(Predicate&); |
| 114 | 114 |
| 115 template<typename VisitorDispatcher> void trace(VisitorDispatcher); | 115 void trace(typename Allocator::Visitor*); |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 friend class DequeIteratorBase<T, inlineCapacity, Allocator>; | 118 friend class DequeIteratorBase<T, inlineCapacity, Allocator>; |
| 119 | 119 |
| 120 typedef VectorBuffer<T, inlineCapacity, Allocator> Buffer; | 120 typedef VectorBuffer<T, inlineCapacity, Allocator> Buffer; |
| 121 typedef VectorTypeOperations<T> TypeOperations; | 121 typedef VectorTypeOperations<T> TypeOperations; |
| 122 typedef DequeIteratorBase<T, inlineCapacity, Allocator> IteratorBase; | 122 typedef DequeIteratorBase<T, inlineCapacity, Allocator> IteratorBase; |
| 123 | 123 |
| 124 void remove(size_t position); | 124 void remove(size_t position); |
| 125 void destroyAll(); | 125 void destroyAll(); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 { | 513 { |
| 514 ASSERT(m_index != m_deque->m_start); | 514 ASSERT(m_index != m_deque->m_start); |
| 515 if (!m_index) | 515 if (!m_index) |
| 516 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]
; | 516 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]
; |
| 517 return &m_deque->m_buffer.buffer()[m_index - 1]; | 517 return &m_deque->m_buffer.buffer()[m_index - 1]; |
| 518 } | 518 } |
| 519 | 519 |
| 520 // This is only called if the allocator is a HeapAllocator. It is used when | 520 // This is only called if the allocator is a HeapAllocator. It is used when |
| 521 // visiting during a tracing GC. | 521 // visiting during a tracing GC. |
| 522 template<typename T, size_t inlineCapacity, typename Allocator> | 522 template<typename T, size_t inlineCapacity, typename Allocator> |
| 523 template<typename VisitorDispatcher> | 523 void Deque<T, inlineCapacity, Allocator>::trace(typename Allocator::Visitor*
visitor) |
| 524 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) | |
| 525 { | 524 { |
| 526 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab
led. | 525 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab
led. |
| 527 const T* bufferBegin = m_buffer.buffer(); | 526 const T* bufferBegin = m_buffer.buffer(); |
| 528 const T* end = bufferBegin + m_end; | 527 const T* end = bufferBegin + m_end; |
| 529 if (ShouldBeTraced<VectorTraits<T> >::value) { | 528 if (ShouldBeTraced<VectorTraits<T> >::value) { |
| 530 if (m_start <= m_end) { | 529 if (m_start <= m_end) { |
| 531 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry !
= end; bufferEntry++) | 530 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry !
= end; bufferEntry++) |
| 532 Allocator::template trace<VisitorDispatcher, T, VectorTraits
<T> >(visitor, *const_cast<T*>(bufferEntry)); | 531 Allocator::template trace<T, VectorTraits<T> >(visitor, *con
st_cast<T*>(bufferEntry)); |
| 533 } else { | 532 } else { |
| 534 for (const T* bufferEntry = bufferBegin; bufferEntry != end; buf
ferEntry++) | 533 for (const T* bufferEntry = bufferBegin; bufferEntry != end; buf
ferEntry++) |
| 535 Allocator::template trace<VisitorDispatcher, T, VectorTraits
<T> >(visitor, *const_cast<T*>(bufferEntry)); | 534 Allocator::template trace<T, VectorTraits<T> >(visitor, *con
st_cast<T*>(bufferEntry)); |
| 536 const T* bufferEnd = m_buffer.buffer() + m_buffer.capacity(); | 535 const T* bufferEnd = m_buffer.buffer() + m_buffer.capacity(); |
| 537 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry !
= bufferEnd; bufferEntry++) | 536 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry !
= bufferEnd; bufferEntry++) |
| 538 Allocator::template trace<VisitorDispatcher, T, VectorTraits
<T> >(visitor, *const_cast<T*>(bufferEntry)); | 537 Allocator::template trace<T, VectorTraits<T> >(visitor, *con
st_cast<T*>(bufferEntry)); |
| 539 } | 538 } |
| 540 } | 539 } |
| 541 if (m_buffer.hasOutOfLineBuffer()) | 540 if (m_buffer.hasOutOfLineBuffer()) |
| 542 Allocator::markNoTracing(visitor, m_buffer.buffer()); | 541 Allocator::markNoTracing(visitor, m_buffer.buffer()); |
| 543 } | 542 } |
| 544 | 543 |
| 545 template<typename T, size_t inlineCapacity, typename Allocator> | 544 template<typename T, size_t inlineCapacity, typename Allocator> |
| 546 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapa
city, Allocator>& b) | 545 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapa
city, Allocator>& b) |
| 547 { | 546 { |
| 548 a.swap(b); | 547 a.swap(b); |
| 549 } | 548 } |
| 550 | 549 |
| 551 #if !ENABLE(OILPAN) | 550 #if !ENABLE(OILPAN) |
| 552 template<typename T, size_t N> | 551 template<typename T, size_t N> |
| 553 struct NeedsTracing<Deque<T, N> > { | 552 struct NeedsTracing<Deque<T, N> > { |
| 554 static const bool value = false; | 553 static const bool value = false; |
| 555 }; | 554 }; |
| 556 #endif | 555 #endif |
| 557 | 556 |
| 558 } // namespace WTF | 557 } // namespace WTF |
| 559 | 558 |
| 560 using WTF::Deque; | 559 using WTF::Deque; |
| 561 | 560 |
| 562 #endif // WTF_Deque_h | 561 #endif // WTF_Deque_h |
| OLD | NEW |