Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(937)

Side by Side Diff: Source/wtf/Deque.h

Issue 24980002: Implement AP2 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/v8/custom/V8PromiseCustom.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 reverse_iterator rend() { return reverse_iterator(begin()); } 72 reverse_iterator rend() { return reverse_iterator(begin()); }
73 const_reverse_iterator rbegin() const { return const_reverse_iterator(en d()); } 73 const_reverse_iterator rbegin() const { return const_reverse_iterator(en d()); }
74 const_reverse_iterator rend() const { return const_reverse_iterator(begi n()); } 74 const_reverse_iterator rend() const { return const_reverse_iterator(begi n()); }
75 75
76 T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start] ; } 76 T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start] ; }
77 const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffe r()[m_start]; } 77 const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffe r()[m_start]; }
78 PassType takeFirst(); 78 PassType takeFirst();
79 79
80 T& last() { ASSERT(m_start != m_end); return *(--end()); } 80 T& last() { ASSERT(m_start != m_end); return *(--end()); }
81 const T& last() const { ASSERT(m_start != m_end); return *(--end()); } 81 const T& last() const { ASSERT(m_start != m_end); return *(--end()); }
82 PassType takeLast();
82 83
83 template<typename U> void append(const U&); 84 template<typename U> void append(const U&);
84 template<typename U> void prepend(const U&); 85 template<typename U> void prepend(const U&);
85 void removeFirst(); 86 void removeFirst();
87 void removeLast();
86 void remove(iterator&); 88 void remove(iterator&);
87 void remove(const_iterator&); 89 void remove(const_iterator&);
88 90
89 void clear(); 91 void clear();
90 92
91 template<typename Predicate> 93 template<typename Predicate>
92 iterator findIf(Predicate&); 94 iterator findIf(Predicate&);
93 95
94 private: 96 private:
95 friend class DequeIteratorBase<T, inlineCapacity>; 97 friend class DequeIteratorBase<T, inlineCapacity>;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 321 }
320 322
321 template<typename T, size_t inlineCapacity> 323 template<typename T, size_t inlineCapacity>
322 inline typename Deque<T, inlineCapacity>::PassType Deque<T, inlineCapacity>: :takeFirst() 324 inline typename Deque<T, inlineCapacity>::PassType Deque<T, inlineCapacity>: :takeFirst()
323 { 325 {
324 T oldFirst = Pass::transfer(first()); 326 T oldFirst = Pass::transfer(first());
325 removeFirst(); 327 removeFirst();
326 return Pass::transfer(oldFirst); 328 return Pass::transfer(oldFirst);
327 } 329 }
328 330
331 template<typename T, size_t inlineCapacity>
332 inline typename Deque<T, inlineCapacity>::PassType Deque<T, inlineCapacity>: :takeLast()
333 {
334 T oldLast = Pass::transfer(last());
335 removeLast();
336 return Pass::transfer(oldLast);
337 }
338
329 template<typename T, size_t inlineCapacity> template<typename U> 339 template<typename T, size_t inlineCapacity> template<typename U>
330 inline void Deque<T, inlineCapacity>::append(const U& value) 340 inline void Deque<T, inlineCapacity>::append(const U& value)
331 { 341 {
332 expandCapacityIfNeeded(); 342 expandCapacityIfNeeded();
333 new (NotNull, &m_buffer.buffer()[m_end]) T(value); 343 new (NotNull, &m_buffer.buffer()[m_end]) T(value);
334 if (m_end == m_buffer.capacity() - 1) 344 if (m_end == m_buffer.capacity() - 1)
335 m_end = 0; 345 m_end = 0;
336 else 346 else
337 ++m_end; 347 ++m_end;
338 } 348 }
(...skipping 14 matching lines...) Expand all
353 { 363 {
354 ASSERT(!isEmpty()); 364 ASSERT(!isEmpty());
355 TypeOperations::destruct(&m_buffer.buffer()[m_start], &m_buffer.buffer() [m_start + 1]); 365 TypeOperations::destruct(&m_buffer.buffer()[m_start], &m_buffer.buffer() [m_start + 1]);
356 if (m_start == m_buffer.capacity() - 1) 366 if (m_start == m_buffer.capacity() - 1)
357 m_start = 0; 367 m_start = 0;
358 else 368 else
359 ++m_start; 369 ++m_start;
360 } 370 }
361 371
362 template<typename T, size_t inlineCapacity> 372 template<typename T, size_t inlineCapacity>
373 inline void Deque<T, inlineCapacity>::removeLast()
374 {
375 ASSERT(!isEmpty());
376 if (!m_end)
377 m_end = m_buffer.capacity() - 1;
378 else
379 --m_end;
380 TypeOperations::destruct(&m_buffer.buffer()[m_end], &m_buffer.buffer()[m _end + 1]);
381 }
382
383 template<typename T, size_t inlineCapacity>
363 inline void Deque<T, inlineCapacity>::remove(iterator& it) 384 inline void Deque<T, inlineCapacity>::remove(iterator& it)
364 { 385 {
365 remove(it.m_index); 386 remove(it.m_index);
366 } 387 }
367 388
368 template<typename T, size_t inlineCapacity> 389 template<typename T, size_t inlineCapacity>
369 inline void Deque<T, inlineCapacity>::remove(const_iterator& it) 390 inline void Deque<T, inlineCapacity>::remove(const_iterator& it)
370 { 391 {
371 remove(it.m_index); 392 remove(it.m_index);
372 } 393 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 if (!m_index) 486 if (!m_index)
466 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1] ; 487 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1] ;
467 return &m_deque->m_buffer.buffer()[m_index - 1]; 488 return &m_deque->m_buffer.buffer()[m_index - 1];
468 } 489 }
469 490
470 } // namespace WTF 491 } // namespace WTF
471 492
472 using WTF::Deque; 493 using WTF::Deque;
473 494
474 #endif // WTF_Deque_h 495 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8PromiseCustom.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698