| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; } | 77 T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; } |
| 78 const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffer()[
m_start]; } | 78 const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffer()[
m_start]; } |
| 79 T takeFirst(); | 79 T takeFirst(); |
| 80 | 80 |
| 81 T& last() { ASSERT(m_start != m_end); return *(--end()); } | 81 T& last() { ASSERT(m_start != m_end); return *(--end()); } |
| 82 const T& last() const { ASSERT(m_start != m_end); return *(--end()); } | 82 const T& last() const { ASSERT(m_start != m_end); return *(--end()); } |
| 83 T takeLast(); | 83 T takeLast(); |
| 84 | 84 |
| 85 T& at(size_t i) | 85 T& at(size_t i) |
| 86 { | 86 { |
| 87 RELEASE_ASSERT(i < size()); | 87 CHECK_LT(i, size()); |
| 88 size_t right = m_buffer.capacity() - m_start; | 88 size_t right = m_buffer.capacity() - m_start; |
| 89 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; | 89 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; |
| 90 } | 90 } |
| 91 const T& at(size_t i) const | 91 const T& at(size_t i) const |
| 92 { | 92 { |
| 93 RELEASE_ASSERT(i < size()); | 93 CHECK_LT(i, size()); |
| 94 size_t right = m_buffer.capacity() - m_start; | 94 size_t right = m_buffer.capacity() - m_start; |
| 95 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; | 95 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; |
| 96 } | 96 } |
| 97 | 97 |
| 98 T& operator[](size_t i) { return at(i); } | 98 T& operator[](size_t i) { return at(i); } |
| 99 const T& operator[](size_t i) const { return at(i); } | 99 const T& operator[](size_t i) const { return at(i); } |
| 100 | 100 |
| 101 template <typename U> void append(U&&); | 101 template <typename U> void append(U&&); |
| 102 template <typename U> void prepend(U&&); | 102 template <typename U> void prepend(U&&); |
| 103 void removeFirst(); | 103 void removeFirst(); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 ASSERT(m_deque->m_buffer.capacity()); | 567 ASSERT(m_deque->m_buffer.capacity()); |
| 568 if (!m_index) | 568 if (!m_index) |
| 569 m_index = m_deque->m_buffer.capacity() - 1; | 569 m_index = m_deque->m_buffer.capacity() - 1; |
| 570 else | 570 else |
| 571 --m_index; | 571 --m_index; |
| 572 } | 572 } |
| 573 | 573 |
| 574 template <typename T, size_t inlineCapacity, typename Allocator> | 574 template <typename T, size_t inlineCapacity, typename Allocator> |
| 575 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const | 575 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const |
| 576 { | 576 { |
| 577 RELEASE_ASSERT(m_index != m_deque->m_end); | 577 CHECK_NE(m_index, m_deque->m_end); |
| 578 return &m_deque->m_buffer.buffer()[m_index]; | 578 return &m_deque->m_buffer.buffer()[m_index]; |
| 579 } | 579 } |
| 580 | 580 |
| 581 template <typename T, size_t inlineCapacity, typename Allocator> | 581 template <typename T, size_t inlineCapacity, typename Allocator> |
| 582 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const | 582 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const |
| 583 { | 583 { |
| 584 RELEASE_ASSERT(m_index != m_deque->m_start); | 584 CHECK_NE(m_index, m_deque->m_start); |
| 585 if (!m_index) | 585 if (!m_index) |
| 586 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]; | 586 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]; |
| 587 return &m_deque->m_buffer.buffer()[m_index - 1]; | 587 return &m_deque->m_buffer.buffer()[m_index - 1]; |
| 588 } | 588 } |
| 589 | 589 |
| 590 // This is only called if the allocator is a HeapAllocator. It is used when | 590 // This is only called if the allocator is a HeapAllocator. It is used when |
| 591 // visiting during a tracing GC. | 591 // visiting during a tracing GC. |
| 592 template <typename T, size_t inlineCapacity, typename Allocator> | 592 template <typename T, size_t inlineCapacity, typename Allocator> |
| 593 template <typename VisitorDispatcher> | 593 template <typename VisitorDispatcher> |
| 594 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) | 594 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 616 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapacity
, Allocator>& b) | 616 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapacity
, Allocator>& b) |
| 617 { | 617 { |
| 618 a.swap(b); | 618 a.swap(b); |
| 619 } | 619 } |
| 620 | 620 |
| 621 } // namespace WTF | 621 } // namespace WTF |
| 622 | 622 |
| 623 using WTF::Deque; | 623 using WTF::Deque; |
| 624 | 624 |
| 625 #endif // WTF_Deque_h | 625 #endif // WTF_Deque_h |
| OLD | NEW |