EMAN2
libEM
gorgon
grid_queue2.cpp
Go to the documentation of this file.
1
// Copyright (C) 2005-2008 Washington University in St Louis, Baylor College of Medicine. All rights reserved
2
// Author: Tao Ju, Refactored by Sasakthi S. Abeysinghe (sasakthi@gmail.com)
3
// Description: Grid queue
4
5
#include "
grid_queue2.h
"
6
7
using namespace
wustl_mm::SkeletonMaker
;
8
9
GridQueue2::GridQueue2( )
10
{
11
head
= NULL ;
12
cur
= NULL ;
13
pre
= NULL ;
14
prepre
= NULL ;
15
numEles
= 0 ;
16
}
17
18
GridQueue2::~GridQueue2
()
19
{
20
gridQueueEle
* ele;
21
reset
();
22
ele=
getNext
();
23
while
( (ele=
remove
()) != NULL ){};
24
}
25
gridQueueEle
*
GridQueue2::getNext
( )
26
{
27
if
(
cur
== NULL )
28
{
29
prepre
= NULL ;
30
pre
= NULL ;
31
cur
=
head
;
32
}
33
else
34
{
35
prepre
=
pre
;
36
pre
=
cur
;
37
cur
=
cur
->
next
;
38
}
39
40
return
cur
;
41
}
42
43
void
GridQueue2::reset
( )
44
{
45
prepre
= NULL ;
46
pre
= NULL ;
47
cur
= NULL ;
48
}
49
50
int
GridQueue2::getNumElements
( )
51
{
52
return
numEles
;
53
}
54
55
void
GridQueue2::prepend
(
int
xx,
int
yy,
int
zz )
56
{
57
gridQueueEle
* ele =
new
gridQueueEle
;
58
ele->
x
= xx ;
59
ele->
y
= yy ;
60
ele->
z
= zz ;
61
ele->
score
= 0 ;
62
ele->
next
=
head
;
63
head
= ele ;
64
numEles
++ ;
65
66
reset
() ;
67
}
68
69
/* Remove current element pointed by cur */
70
gridQueueEle
*
GridQueue2::remove
( )
71
{
72
gridQueueEle
* temp =
cur
;
73
if
(
cur
!= NULL )
74
{
75
cur
=
cur
->
next
;
76
delete
temp ;
77
78
if
(
pre
!= NULL )
79
{
80
pre
->
next
=
cur
;
81
}
82
else
83
{
84
head
=
cur
;
85
}
86
numEles
-- ;
87
}
88
89
90
return
cur
;
91
}
92
93
/* Switching pre and cur */
94
gridQueueEle
*
GridQueue2::swap
( )
95
{
96
if
(
prepre
!= NULL )
97
{
98
pre
->
next
=
cur
->
next
;
99
cur
->
next
=
prepre
->
next
;
100
prepre
->
next
=
cur
;
101
102
}
103
else
104
{
105
pre
->
next
=
cur
->
next
;
106
cur
->
next
=
pre
;
107
head
=
cur
;
108
}
109
110
gridQueueEle
* temp =
pre
;
111
pre
=
cur
;
112
cur
= temp ;
113
114
return
cur
;
115
}
wustl_mm::SkeletonMaker::GridQueue2::swap
gridQueueEle * swap()
Definition:
grid_queue2.cpp:94
wustl_mm::SkeletonMaker::GridQueue2::prepre
gridQueueEle * prepre
Definition:
grid_queue2.h:27
wustl_mm::SkeletonMaker::GridQueue2::numEles
int numEles
Definition:
grid_queue2.h:29
wustl_mm::SkeletonMaker::GridQueue2::getNumElements
int getNumElements()
Definition:
grid_queue2.cpp:50
wustl_mm::SkeletonMaker::GridQueue2::reset
void reset()
Definition:
grid_queue2.cpp:43
wustl_mm::SkeletonMaker::GridQueue2::remove
gridQueueEle * remove()
Definition:
grid_queue2.cpp:70
wustl_mm::SkeletonMaker::GridQueue2::head
gridQueueEle * head
Definition:
grid_queue2.h:25
wustl_mm::SkeletonMaker::GridQueue2::pre
gridQueueEle * pre
Definition:
grid_queue2.h:26
wustl_mm::SkeletonMaker::GridQueue2::~GridQueue2
~GridQueue2()
Definition:
grid_queue2.cpp:18
wustl_mm::SkeletonMaker::GridQueue2::cur
gridQueueEle * cur
Definition:
grid_queue2.h:28
wustl_mm::SkeletonMaker::GridQueue2::getNext
gridQueueEle * getNext()
Definition:
grid_queue2.cpp:25
wustl_mm::SkeletonMaker::GridQueue2::prepend
void prepend(int xx, int yy, int zz)
Definition:
grid_queue2.cpp:55
grid_queue2.h
wustl_mm::SkeletonMaker
Definition:
grid_queue.h:13
wustl_mm::SkeletonMaker::gridQueueEle
Definition:
grid_queue.h:15
wustl_mm::SkeletonMaker::gridQueueEle::score
int score
Definition:
grid_queue.h:17
wustl_mm::SkeletonMaker::gridQueueEle::y
int y
Definition:
grid_queue.h:16
wustl_mm::SkeletonMaker::gridQueueEle::x
int x
Definition:
grid_queue.h:16
wustl_mm::SkeletonMaker::gridQueueEle::next
gridQueueEle * next
Definition:
grid_queue.h:18
wustl_mm::SkeletonMaker::gridQueueEle::z
int z
Definition:
grid_queue.h:16
Generated by
1.9.2