| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; } | 75 T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; } |
| 76 const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffer()[
m_start]; } | 76 const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffer()[
m_start]; } |
| 77 T takeFirst(); | 77 T takeFirst(); |
| 78 | 78 |
| 79 T& last() { ASSERT(m_start != m_end); return *(--end()); } | 79 T& last() { ASSERT(m_start != m_end); return *(--end()); } |
| 80 const T& last() const { ASSERT(m_start != m_end); return *(--end()); } | 80 const T& last() const { ASSERT(m_start != m_end); return *(--end()); } |
| 81 T takeLast(); | 81 T takeLast(); |
| 82 | 82 |
| 83 T& at(size_t i) | 83 T& at(size_t i) |
| 84 { | 84 { |
| 85 RELEASE_ASSERT(i < size()); | 85 CHECK_LT(i, size()); |
| 86 size_t right = m_buffer.capacity() - m_start; | 86 size_t right = m_buffer.capacity() - m_start; |
| 87 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; | 87 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; |
| 88 } | 88 } |
| 89 const T& at(size_t i) const | 89 const T& at(size_t i) const |
| 90 { | 90 { |
| 91 RELEASE_ASSERT(i < size()); | 91 CHECK_LT(i, size()); |
| 92 size_t right = m_buffer.capacity() - m_start; | 92 size_t right = m_buffer.capacity() - m_start; |
| 93 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; | 93 return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i
- right]; |
| 94 } | 94 } |
| 95 | 95 |
| 96 T& operator[](size_t i) { return at(i); } | 96 T& operator[](size_t i) { return at(i); } |
| 97 const T& operator[](size_t i) const { return at(i); } | 97 const T& operator[](size_t i) const { return at(i); } |
| 98 | 98 |
| 99 template <typename U> void append(U&&); | 99 template <typename U> void append(U&&); |
| 100 template <typename U> void prepend(U&&); | 100 template <typename U> void prepend(U&&); |
| 101 void removeFirst(); | 101 void removeFirst(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 ASSERT(m_deque->m_buffer.capacity()); | 551 ASSERT(m_deque->m_buffer.capacity()); |
| 552 if (!m_index) | 552 if (!m_index) |
| 553 m_index = m_deque->m_buffer.capacity() - 1; | 553 m_index = m_deque->m_buffer.capacity() - 1; |
| 554 else | 554 else |
| 555 --m_index; | 555 --m_index; |
| 556 } | 556 } |
| 557 | 557 |
| 558 template <typename T, size_t inlineCapacity, typename Allocator> | 558 template <typename T, size_t inlineCapacity, typename Allocator> |
| 559 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const | 559 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const |
| 560 { | 560 { |
| 561 RELEASE_ASSERT(m_index != m_deque->m_end); | 561 CHECK_NE(m_index, m_deque->m_end); |
| 562 return &m_deque->m_buffer.buffer()[m_index]; | 562 return &m_deque->m_buffer.buffer()[m_index]; |
| 563 } | 563 } |
| 564 | 564 |
| 565 template <typename T, size_t inlineCapacity, typename Allocator> | 565 template <typename T, size_t inlineCapacity, typename Allocator> |
| 566 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const | 566 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const |
| 567 { | 567 { |
| 568 RELEASE_ASSERT(m_index != m_deque->m_start); | 568 CHECK_NE(m_index, m_deque->m_start); |
| 569 if (!m_index) | 569 if (!m_index) |
| 570 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]; | 570 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]; |
| 571 return &m_deque->m_buffer.buffer()[m_index - 1]; | 571 return &m_deque->m_buffer.buffer()[m_index - 1]; |
| 572 } | 572 } |
| 573 | 573 |
| 574 // This is only called if the allocator is a HeapAllocator. It is used when | 574 // This is only called if the allocator is a HeapAllocator. It is used when |
| 575 // visiting during a tracing GC. | 575 // visiting during a tracing GC. |
| 576 template <typename T, size_t inlineCapacity, typename Allocator> | 576 template <typename T, size_t inlineCapacity, typename Allocator> |
| 577 template <typename VisitorDispatcher> | 577 template <typename VisitorDispatcher> |
| 578 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) | 578 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 607 struct NeedsTracing<Deque<T, N>> { | 607 struct NeedsTracing<Deque<T, N>> { |
| 608 static const bool value = false; | 608 static const bool value = false; |
| 609 }; | 609 }; |
| 610 #endif | 610 #endif |
| 611 | 611 |
| 612 } // namespace WTF | 612 } // namespace WTF |
| 613 | 613 |
| 614 using WTF::Deque; | 614 using WTF::Deque; |
| 615 | 615 |
| 616 #endif // WTF_Deque_h | 616 #endif // WTF_Deque_h |
| OLD | NEW |