EMAN2
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
7using 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
19 {
20 gridQueueEle* ele;
21 reset();
22 ele=getNext();
23 while ( (ele=remove()) != NULL ){};
24 }
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
44 {
45 prepre = NULL ;
46 pre = NULL ;
47 cur = NULL ;
48 }
49
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 */
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 */
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 }
void prepend(int xx, int yy, int zz)
Definition: grid_queue2.cpp:55