OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef PODInterval_h | 26 #ifndef PODInterval_h |
27 #define PODInterval_h | 27 #define PODInterval_h |
28 | 28 |
29 #ifndef NDEBUG | 29 #ifndef NDEBUG |
30 #include "wtf/text/StringBuilder.h" | 30 #include "wtf/text/StringBuilder.h" |
31 #endif | 31 #endif |
32 | 32 |
33 namespace WebCore { | 33 namespace blink { |
34 | 34 |
35 // Class representing a closed interval which can hold an arbitrary | 35 // Class representing a closed interval which can hold an arbitrary |
36 // Plain Old Datatype (POD) as its endpoints and a piece of user | 36 // Plain Old Datatype (POD) as its endpoints and a piece of user |
37 // data. An important characteristic for the algorithms we use is that | 37 // data. An important characteristic for the algorithms we use is that |
38 // if two intervals have identical endpoints but different user data, | 38 // if two intervals have identical endpoints but different user data, |
39 // they are not considered to be equal. This situation can arise when | 39 // they are not considered to be equal. This situation can arise when |
40 // representing the vertical extents of bounding boxes of overlapping | 40 // representing the vertical extents of bounding boxes of overlapping |
41 // triangles, where the pointer to the triangle is the user data of | 41 // triangles, where the pointer to the triangle is the user data of |
42 // the interval. | 42 // the interval. |
43 // | 43 // |
44 // *Note* that the destructors of type T and UserData will *not* be | 44 // *Note* that the destructors of type T and UserData will *not* be |
45 // called by this class. They must not allocate any memory that is | 45 // called by this class. They must not allocate any memory that is |
46 // required to be cleaned up in their destructors. | 46 // required to be cleaned up in their destructors. |
47 // | 47 // |
48 // The following constructors and operators must be implemented on | 48 // The following constructors and operators must be implemented on |
49 // type T: | 49 // type T: |
50 // | 50 // |
51 // - Copy constructor (if user data is desired) | 51 // - Copy constructor (if user data is desired) |
52 // - operator< | 52 // - operator< |
53 // - operator== | 53 // - operator== |
54 // - operator= | 54 // - operator= |
55 // | 55 // |
56 // If the UserData type is specified, it must support a copy | 56 // If the UserData type is specified, it must support a copy |
57 // constructor and assignment operator. | 57 // constructor and assignment operator. |
58 // | 58 // |
59 // In debug mode, printing of intervals and the data they contain is | 59 // In debug mode, printing of intervals and the data they contain is |
60 // enabled. This requires the following template specializations to be | 60 // enabled. This requires the following template specializations to be |
61 // available: | 61 // available: |
62 // | 62 // |
63 // template<> struct WebCore::ValueToString<T> { | 63 // template<> struct blink::ValueToString<T> { |
64 // static String string(const T& t); | 64 // static String string(const T& t); |
65 // }; | 65 // }; |
66 // template<> struct WebCore::ValueToString<UserData> { | 66 // template<> struct blink::ValueToString<UserData> { |
67 // static String string(const UserData& t); | 67 // static String string(const UserData& t); |
68 // }; | 68 // }; |
69 // | 69 // |
70 // Note that this class requires a copy constructor and assignment | 70 // Note that this class requires a copy constructor and assignment |
71 // operator in order to be stored in the red-black tree. | 71 // operator in order to be stored in the red-black tree. |
72 | 72 |
73 #ifndef NDEBUG | 73 #ifndef NDEBUG |
74 template<class T> | 74 template<class T> |
75 struct ValueToString; | 75 struct ValueToString; |
76 #endif | 76 #endif |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 #endif | 152 #endif |
153 | 153 |
154 private: | 154 private: |
155 T m_low; | 155 T m_low; |
156 T m_high; | 156 T m_high; |
157 UserData m_data; | 157 UserData m_data; |
158 T m_maxHigh; | 158 T m_maxHigh; |
159 }; | 159 }; |
160 | 160 |
161 } // namespace WebCore | 161 } // namespace blink |
162 | 162 |
163 #endif // PODInterval_h | 163 #endif // PODInterval_h |
OLD | NEW |