Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

disjoint-set.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2006 Pedro Felzenszwalb
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (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
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 */
00018 
00019 /*
00020  * 05/27/2007
00021  * Edited by pthoren@cs.uml.edu:
00022  * Moved implementation/source code into a source file.
00023  * Formating to my own crazy standards.
00024  */
00025 
00026 // disjoint-set forests using union-by-rank and path compression (sort of).
00027 
00028 #ifndef DISJOINT_SET
00029 #define DISJOINT_SET
00030 
00031 typedef struct uni_elt_t
00032 {
00033     int rank;
00034     int p;
00035     int size;
00036 } uni_elt;
00037 
00038 class universe 
00039 {
00040 private:
00041     uni_elt    *elts;
00042     int         num;
00043 
00044 public:
00045     universe( int elements );
00046     ~universe();
00047 
00048     int     find    ( int x );  
00049     void    join    ( int x, int y);
00050     int     size    ( int x ) const;
00051     int     num_sets() const;
00052 
00053 };
00054 
00055 
00056 #endif




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:05 2007 for phission by  doxygen 1.4.4