Last change
on this file since 2376 was
2096,
checked in by ldelgass, 13 years ago
|
Normalize line endings, set eol-style to native on *.cpp, *.h files
|
-
Property svn:eol-style set to
native
|
File size:
1.4 KB
|
Line | |
---|
1 | #ifndef __BUCKETSORT_H_ |
---|
2 | #define __BUCKETSORT_H_ |
---|
3 | |
---|
4 | #include <vector> |
---|
5 | #include <list> |
---|
6 | #include "Vector3.h" |
---|
7 | #include "Mat4x4.h" |
---|
8 | #include "PCASplit.h" |
---|
9 | |
---|
10 | namespace PCA { |
---|
11 | |
---|
12 | class ClusterList { |
---|
13 | public : |
---|
14 | Cluster* data; |
---|
15 | ClusterList* next; |
---|
16 | public : |
---|
17 | ClusterList(Cluster* d, ClusterList* n) |
---|
18 | : data(d), next(n) |
---|
19 | {} |
---|
20 | |
---|
21 | ClusterList() |
---|
22 | : data(0), next(0) |
---|
23 | {} |
---|
24 | |
---|
25 | ~ClusterList() |
---|
26 | { |
---|
27 | //if (next) delete next; |
---|
28 | } |
---|
29 | }; |
---|
30 | |
---|
31 | class BucketSort { |
---|
32 | ClusterList** _buffer; |
---|
33 | int _size; |
---|
34 | int _count; |
---|
35 | |
---|
36 | int _memChuckSize; |
---|
37 | bool _memChunckUsedFlag; |
---|
38 | ClusterList* _memChunck; |
---|
39 | |
---|
40 | float _invMaxLength; |
---|
41 | private : |
---|
42 | //void _sort(Cluster* cluster, const Matrix4& cameraMat, int level); |
---|
43 | void _sort(Cluster* cluster, const Mat4x4& cameraMat, int level); |
---|
44 | public : |
---|
45 | BucketSort(int maxSize) |
---|
46 | { |
---|
47 | _size = maxSize; |
---|
48 | _buffer = new ClusterList*[maxSize]; |
---|
49 | memset(_buffer, 0, _size * sizeof(ClusterList*)); |
---|
50 | |
---|
51 | _memChuckSize = 1000000; |
---|
52 | _memChunck = new ClusterList[_memChuckSize]; |
---|
53 | |
---|
54 | _invMaxLength = 1.0f / 4.0f; |
---|
55 | } |
---|
56 | |
---|
57 | ~BucketSort() |
---|
58 | { |
---|
59 | delete [] _buffer; |
---|
60 | delete [] _memChunck; |
---|
61 | } |
---|
62 | |
---|
63 | int getSize() const { return _size; } |
---|
64 | int getSortedItemCount() const { return _count; } |
---|
65 | void init(); |
---|
66 | //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, float maxLength); |
---|
67 | //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, int level); |
---|
68 | void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level); |
---|
69 | void addBucket(Cluster* cluster, float ratio); |
---|
70 | ClusterList** getBucket() { return _buffer; } |
---|
71 | }; |
---|
72 | |
---|
73 | } |
---|
74 | |
---|
75 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.