EMAN2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
wustl_mm::SkeletonMaker::GridQueue Class Reference

#include <grid_queue.h>

Collaboration diagram for wustl_mm::SkeletonMaker::GridQueue:
Collaboration graph
[legend]

Public Member Functions

 GridQueue ()
 
gridQueueElegetHead ()
 
int getNumElements ()
 
void sort (int eles)
 
void pushQueue (int xx, int yy, int zz)
 
int popQueue (int &xx, int &yy, int &zz)
 

Private Member Functions

void swapEle (gridQueueEle *pre, gridQueueEle *e1, gridQueueEle *e2)
 

Private Attributes

gridQueueElehead
 
gridQueueEletail
 
int numEles
 

Detailed Description

Definition at line 21 of file grid_queue.h.

Constructor & Destructor Documentation

◆ GridQueue()

GridQueue::GridQueue ( )

Definition at line 8 of file grid_queue.cpp.

8 {
9 head = NULL ;
10 tail = NULL ;
11 numEles = 0 ;
12 }

References head, numEles, and tail.

Member Function Documentation

◆ getHead()

gridQueueEle * GridQueue::getHead ( )

Definition at line 14 of file grid_queue.cpp.

14 {
15 return head ;
16 }

References head.

◆ getNumElements()

int GridQueue::getNumElements ( )

Definition at line 18 of file grid_queue.cpp.

18 {
19 return numEles ;
20 }

References numEles.

◆ popQueue()

int GridQueue::popQueue ( int &  xx,
int &  yy,
int &  zz 
)

Definition at line 88 of file grid_queue.cpp.

88 {
89 if ( head == NULL )
90 {
91 return 0 ;
92 }
93
94 xx = head->x ;
95 yy = head->y ;
96 zz = head->z ;
97
98 gridQueueEle* temp = head ;
99 head = head->next ;
100 delete temp ;
101
102 if ( head == NULL )
103 {
104 tail = NULL ;
105 }
106 numEles -- ;
107
108 return 1 ;
109 }

References head, wustl_mm::SkeletonMaker::gridQueueEle::next, numEles, tail, wustl_mm::SkeletonMaker::gridQueueEle::x, wustl_mm::SkeletonMaker::gridQueueEle::y, and wustl_mm::SkeletonMaker::gridQueueEle::z.

◆ pushQueue()

void GridQueue::pushQueue ( int  xx,
int  yy,
int  zz 
)

Definition at line 69 of file grid_queue.cpp.

69 {
70 gridQueueEle* ele = new gridQueueEle ;
71 ele->x = xx ;
72 ele->y = yy ;
73 ele->z = zz ;
74 ele->score = 0 ;
75 ele->next = NULL ;
76 if ( head == NULL )
77 {
78 head = ele ;
79 }
80 else
81 {
82 tail->next = ele ;
83 }
84 tail = ele ;
85 numEles ++ ;
86 }

References head, wustl_mm::SkeletonMaker::gridQueueEle::next, numEles, wustl_mm::SkeletonMaker::gridQueueEle::score, tail, wustl_mm::SkeletonMaker::gridQueueEle::x, wustl_mm::SkeletonMaker::gridQueueEle::y, and wustl_mm::SkeletonMaker::gridQueueEle::z.

◆ sort()

void GridQueue::sort ( int  eles)

Definition at line 23 of file grid_queue.cpp.

23 {
24 //printf("Sorting elements with descending scores...\n") ;
25 gridQueueEle* pre ;
26 gridQueueEle* e1 ;
27 gridQueueEle* e2 ;
28
29 for ( int i = eles - 1 ; i > 0 ; i -- )
30 {
31 pre = NULL ;
32 e1 = head ;
33 e2 = e1->next ;
34
35 for ( int j = 0 ; j < i ; j ++ )
36 {
37 if ( e1->score < e2->score )
38 {
39 swapEle( pre, e1, e2 ) ;
40 }
41 else if ( e1->score == e2->score && rand() < RAND_MAX / 2)
42 {
43 swapEle( pre, e1, e2 ) ;
44 }
45
46 if ( pre == NULL )
47 {
48 pre = head ;
49 }
50 else
51 {
52 pre = pre->next;
53 }
54 e1 = pre->next ;
55 e2 = e1->next ;
56 }
57 }
58
59 /* Debugging
60 pre = head ;
61 while ( pre != NULL )
62 {
63 printf("%d ", pre->score ) ;
64 pre = pre->next ;
65 }*/
66 }
void swapEle(gridQueueEle *pre, gridQueueEle *e1, gridQueueEle *e2)
Definition: grid_queue.cpp:112

References head, wustl_mm::SkeletonMaker::gridQueueEle::next, wustl_mm::SkeletonMaker::gridQueueEle::score, and swapEle().

◆ swapEle()

void GridQueue::swapEle ( gridQueueEle pre,
gridQueueEle e1,
gridQueueEle e2 
)
private

Definition at line 112 of file grid_queue.cpp.

113 {
114 if ( pre != NULL )
115 {
116 e1->next = e2->next ;
117 e2->next = pre->next ;
118 pre->next = e2 ;
119
120 if ( tail == e2 )
121 {
122 tail = e1 ;
123 }
124 }
125 else
126 {
127 e1->next = e2->next ;
128 e2->next = e1 ;
129 head = e2 ;
130
131 if ( tail == e2 )
132 {
133 tail = e1 ;
134 }
135 }
136 }

References head, wustl_mm::SkeletonMaker::gridQueueEle::next, and tail.

Referenced by sort().

Member Data Documentation

◆ head

gridQueueEle* wustl_mm::SkeletonMaker::GridQueue::head
private

Definition at line 35 of file grid_queue.h.

Referenced by getHead(), GridQueue(), popQueue(), pushQueue(), sort(), and swapEle().

◆ numEles

int wustl_mm::SkeletonMaker::GridQueue::numEles
private

Definition at line 37 of file grid_queue.h.

Referenced by getNumElements(), GridQueue(), popQueue(), and pushQueue().

◆ tail

gridQueueEle* wustl_mm::SkeletonMaker::GridQueue::tail
private

Definition at line 36 of file grid_queue.h.

Referenced by GridQueue(), popQueue(), pushQueue(), and swapEle().


The documentation for this class was generated from the following files: