Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributor(s): Tao Ju 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00023 #ifndef QUEUE_H 00024 #define QUEUE_H 00025 00026 struct gridQueueEle 00027 { 00028 int x, y, z; 00029 UCHAR dir ; 00030 gridQueueEle* next ; 00031 }; 00032 00033 class GridQueue 00034 { 00035 gridQueueEle* head ; 00036 gridQueueEle* tail ; 00037 int numEles ; 00038 00039 public: 00040 00041 GridQueue( ) 00042 { 00043 head = NULL ; 00044 tail = NULL ; 00045 numEles = 0 ; 00046 } 00047 00048 gridQueueEle* getHead( ) 00049 { 00050 return head ; 00051 } 00052 00053 int getNumElements( ) 00054 { 00055 return numEles ; 00056 } 00057 00058 00059 void pushQueue( int st[3], int dir ) 00060 { 00061 gridQueueEle* ele = new gridQueueEle ; 00062 ele->x = st[0] ; 00063 ele->y = st[1] ; 00064 ele->z = st[2] ; 00065 ele->dir = (UCHAR) dir ; 00066 ele->next = NULL ; 00067 if ( head == NULL ) 00068 { 00069 head = ele ; 00070 } 00071 else 00072 { 00073 tail->next = ele ; 00074 } 00075 tail = ele ; 00076 numEles ++ ; 00077 } 00078 00079 int popQueue( int st[3], int& dir ) 00080 { 00081 if ( head == NULL ) 00082 { 00083 return 0 ; 00084 } 00085 00086 st[0] = head->x ; 00087 st[1] = head->y ; 00088 st[2] = head->z ; 00089 dir = (int) (head->dir) ; 00090 00091 gridQueueEle* temp = head ; 00092 head = head->next ; 00093 delete temp ; 00094 00095 if ( head == NULL ) 00096 { 00097 tail = NULL ; 00098 } 00099 numEles -- ; 00100 00101 return 1 ; 00102 } 00103 00104 }; 00105 00106 00107 00108 00109 00110 #endif