Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / wtf / Deque.h
index 8a05517..9ecabec 100644 (file)
@@ -84,6 +84,22 @@ namespace WTF {
         const T& last() const { ASSERT(m_start != m_end); return *(--end()); }
         PassType takeLast();
 
+        T& at(size_t i)
+        {
+            RELEASE_ASSERT(i < size());
+            size_t right = m_buffer.capacity() - m_start;
+            return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i - right];
+        }
+        const T& at(size_t i) const
+        {
+            RELEASE_ASSERT(i < size());
+            size_t right = m_buffer.capacity() - m_start;
+            return i < right ? m_buffer.buffer()[m_start + i] : m_buffer.buffer()[i - right];
+        }
+
+        T& operator[](size_t i) { return at(i); }
+        const T& operator[](size_t i) const { return at(i); }
+
         template<typename U> void append(const U&);
         template<typename U> void prepend(const U&);
         void removeFirst();
@@ -227,15 +243,6 @@ namespace WTF {
     }
 
     template<typename T, size_t inlineCapacity, typename Allocator>
-    void deleteAllValues(const Deque<T, inlineCapacity, Allocator>& collection)
-    {
-        typedef typename Deque<T, inlineCapacity, Allocator>::const_iterator iterator;
-        iterator end = collection.end();
-        for (iterator it = collection.begin(); it != end; ++it)
-            delete *it;
-    }
-
-    template<typename T, size_t inlineCapacity, typename Allocator>
     inline Deque<T, 0, Allocator>& Deque<T, inlineCapacity, Allocator>::operator=(const Deque& other)
     {
         Deque<T> copy(other);
@@ -531,6 +538,12 @@ namespace WTF {
             Allocator::markNoTracing(visitor, m_buffer.buffer());
     }
 
+    template<typename T, size_t inlineCapacity, typename Allocator>
+    inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapacity, Allocator>& b)
+    {
+        a.swap(b);
+    }
+
 #if !ENABLE(OILPAN)
     template<typename T, size_t N>
     struct NeedsTracing<Deque<T, N> > {