OLD | NEW |
1 | 1 |
2 //---------------------------------------------------------------------------- | 2 //---------------------------------------------------------------------------- |
3 // Anti-Grain Geometry - Version 2.3 | 3 // Anti-Grain Geometry - Version 2.3 |
4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) | 4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) |
5 // | 5 // |
6 // Permission to copy, use, modify, sell and distribute this software | 6 // Permission to copy, use, modify, sell and distribute this software |
7 // is granted provided this copyright notice appears in all copies. | 7 // is granted provided this copyright notice appears in all copies. |
8 // This software is provided "as is" without express or implied | 8 // This software is provided "as is" without express or implied |
9 // warranty, and with no claim as to its suitability for any purpose. | 9 // warranty, and with no claim as to its suitability for any purpose. |
10 // | 10 // |
11 //---------------------------------------------------------------------------- | 11 //---------------------------------------------------------------------------- |
12 // Contact: mcseem@antigrain.com | 12 // Contact: mcseem@antigrain.com |
13 // mcseemagg@yahoo.com | 13 // mcseemagg@yahoo.com |
14 // http://www.antigrain.com | 14 // http://www.antigrain.com |
15 //---------------------------------------------------------------------------- | 15 //---------------------------------------------------------------------------- |
16 #ifndef AGG_ARRAY_INCLUDED | 16 #ifndef AGG_ARRAY_INCLUDED |
17 #define AGG_ARRAY_INCLUDED | 17 #define AGG_ARRAY_INCLUDED |
18 #include "agg_basics.h" | 18 #include "agg_basics.h" |
19 namespace agg | 19 namespace agg |
20 { | 20 { |
21 template<class T> class pod_array : public CFX_Object | 21 template<class T> class pod_array |
22 { | 22 { |
23 public: | 23 public: |
24 typedef T value_type; | 24 typedef T value_type; |
25 ~pod_array() | 25 ~pod_array() |
26 { | 26 { |
27 FX_Free(m_array); | 27 FX_Free(m_array); |
28 } | 28 } |
29 pod_array() : m_size(0), m_capacity(0), m_array(0) {} | 29 pod_array() : m_size(0), m_capacity(0), m_array(0) {} |
30 pod_array(unsigned cap, unsigned extra_tail = 0); | 30 pod_array(unsigned cap, unsigned extra_tail = 0); |
31 pod_array(const pod_array<T>&); | 31 pod_array(const pod_array<T>&); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 template<class T> const pod_array<T>& | 151 template<class T> const pod_array<T>& |
152 pod_array<T>::operator = (const pod_array<T>&v) | 152 pod_array<T>::operator = (const pod_array<T>&v) |
153 { | 153 { |
154 allocate(v.m_size); | 154 allocate(v.m_size); |
155 if(v.m_size) { | 155 if(v.m_size) { |
156 FXSYS_memcpy(m_array, v.m_array, sizeof(T) * v.m_size); | 156 FXSYS_memcpy(m_array, v.m_array, sizeof(T) * v.m_size); |
157 } | 157 } |
158 return *this; | 158 return *this; |
159 } | 159 } |
160 template<class T, unsigned S = 6> class pod_deque : public CFX_Object | 160 template<class T, unsigned S = 6> class pod_deque |
161 { | 161 { |
162 public: | 162 public: |
163 enum block_scale_e { | 163 enum block_scale_e { |
164 block_shift = S, | 164 block_shift = S, |
165 block_size = 1 << block_shift, | 165 block_size = 1 << block_shift, |
166 block_mask = block_size - 1 | 166 block_mask = block_size - 1 |
167 }; | 167 }; |
168 typedef T value_type; | 168 typedef T value_type; |
169 ~pod_deque(); | 169 ~pod_deque(); |
170 pod_deque(); | 170 pod_deque(); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 m_size += num_elements; | 402 m_size += num_elements; |
403 return index; | 403 return index; |
404 } | 404 } |
405 return -1; | 405 return -1; |
406 } | 406 } |
407 template<class T, unsigned S> | 407 template<class T, unsigned S> |
408 unsigned pod_deque<T, S>::byte_size() const | 408 unsigned pod_deque<T, S>::byte_size() const |
409 { | 409 { |
410 return m_size * sizeof(T); | 410 return m_size * sizeof(T); |
411 } | 411 } |
412 class pod_allocator : public CFX_Object | 412 class pod_allocator |
413 { | 413 { |
414 public: | 414 public: |
415 void remove_all() | 415 void remove_all() |
416 { | 416 { |
417 if(m_num_blocks) { | 417 if(m_num_blocks) { |
418 int8u** blk = m_blocks + m_num_blocks - 1; | 418 int8u** blk = m_blocks + m_num_blocks - 1; |
419 while(m_num_blocks--) { | 419 while(m_num_blocks--) { |
420 FX_Free(*blk); | 420 FX_Free(*blk); |
421 --blk; | 421 --blk; |
422 } | 422 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 quick_sort_threshold = 9 | 501 quick_sort_threshold = 9 |
502 }; | 502 }; |
503 template<class T> inline void swap_elements(T& a, T& b) | 503 template<class T> inline void swap_elements(T& a, T& b) |
504 { | 504 { |
505 T temp = a; | 505 T temp = a; |
506 a = b; | 506 a = b; |
507 b = temp; | 507 b = temp; |
508 } | 508 } |
509 } | 509 } |
510 #endif | 510 #endif |
OLD | NEW |