00001 /* BurrTools 00002 * 00003 * BurrTools is the legal property of its developers, whose 00004 * names are listed in the COPYRIGHT file, which is included 00005 * within the source distribution. 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 */ 00021 #ifndef __GROUPING_H__ 00022 #define __GROUPING_H__ 00023 00024 #include <vector> 00025 00056 class grouping_c { 00057 00058 struct set { 00059 unsigned int currentGroup; 00060 00061 std::vector<unsigned int> pieces; 00062 }; 00063 00064 std::vector<set> sets; 00065 00066 struct piece { 00067 unsigned int piece; 00068 unsigned int group; 00069 int count; 00070 }; 00071 00072 std::vector<piece> pieces; 00073 00074 unsigned int numGroups; 00075 00076 unsigned int findPiece(unsigned int pc, unsigned int gp) { 00077 unsigned int i; 00078 00079 for (i = 0; i < pieces.size(); i++) 00080 if ((pieces[i].piece == pc) && (pieces[i].group == gp)) 00081 break; 00082 00083 return i; 00084 } 00085 00086 bool failed; 00087 00088 public: 00089 00090 00091 grouping_c(void) : numGroups(0), failed(false) {} 00092 00098 void addPieces(unsigned int pc, unsigned int group, unsigned int count); 00099 00101 void reSet(void); 00102 00106 void newSet(void); 00107 00115 bool addPieceToSet(unsigned int pc); 00116 00117 private: 00118 00119 // no copying and assigning 00120 grouping_c(const grouping_c&); 00121 void operator=(const grouping_c&); 00122 }; 00123 00124 #endif