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

Unified Diff: third_party/WebKit/Source/wtf/Vector.h

Issue 2690953002: WTF: Update comments for Vector. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/Vector.h
diff --git a/third_party/WebKit/Source/wtf/Vector.h b/third_party/WebKit/Source/wtf/Vector.h
index 9b068f1cf5d160133f12d2b49a7fb99805bd211a..9483a550d1d182afa15bdd7cd81ff2e9baf536b4 100644
--- a/third_party/WebKit/Source/wtf/Vector.h
+++ b/third_party/WebKit/Source/wtf/Vector.h
@@ -57,6 +57,14 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
template <typename T, size_t inlineBuffer, typename Allocator>
class Deque;
+//
+// Vector Traits
+//
+
+// Bunch of traits for Vector are defined here, with which you can customize
+// Vector's behavior. In most cases the default traits are appropriate, so you
+// usually don't have to specialize those traits by yourself.
+
template <bool needsDestruction, typename T>
struct VectorDestructor;
@@ -279,6 +287,9 @@ struct VectorElementComparer<std::unique_ptr<T>> {
}
};
+// A collection of all the traits used by Vector. This is basically an
+// implementation detail of Vector, and you should specialize individual traits
+// defined above, if you want to customize Vector's behavior.
template <typename T>
struct VectorTypeOperations {
STATIC_ONLY(VectorTypeOperations);
@@ -327,6 +338,16 @@ struct VectorTypeOperations {
}
};
+//
+// VectorBuffer
+//
+
+// VectorBuffer is an implementation detail of Vector and Deque. It manages
+// Vector's underlying buffer, and does operations like allocation or
+// expansion.
+//
+// Not meant for general consumption.
+
template <typename T, bool hasInlineCapacity, typename Allocator>
class VectorBufferBase {
WTF_MAKE_NONCOPYABLE(VectorBufferBase);
@@ -795,12 +816,17 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> {
template <typename U, size_t inlineBuffer, typename V>
friend class Deque;
};
-// Heap-allocated vectors with no inlineCapacity never need a destructor.
+
+//
+// Vector
+//
+
template <typename T,
size_t inlineCapacity = 0,
typename Allocator = PartitionAllocator>
class Vector
: private VectorBuffer<T, INLINE_CAPACITY, Allocator>,
+ // Heap-allocated vectors with no inlineCapacity never need a destructor.
public ConditionalDestructor<Vector<T, INLINE_CAPACITY, Allocator>,
(INLINE_CAPACITY == 0) &&
Allocator::isGarbageCollected> {
@@ -1040,6 +1066,10 @@ class Vector
using Base::allocationSize;
};
+//
+// Vector out-of-line implementation
+//
+
template <typename T, size_t inlineCapacity, typename Allocator>
Vector<T, inlineCapacity, Allocator>::Vector(const Vector& other)
: Base(other.capacity()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698