Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

sparse3d.h

00001 /*
00002     Sparse 3-D matrix.
00003     Copyright (C) 1998-2001 by Jorrit Tyberghein
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __SPARSE3D_H__
00021 #define __SPARSE3D_H__
00022 
00027 class csSparse3D
00028 {
00029 public:
00031   csSparse3D () { }
00033   virtual ~csSparse3D () { }
00034 
00036   virtual void Clear () = 0;
00037 
00039   virtual void Set (int x, int y, int z, void* obj) = 0;
00040 
00042   virtual void* Get (int x, int y, int z) = 0;
00043 
00045   virtual void Del (int x, int y, int z) = 0;
00046 };
00047 
00061 class csWideSparse3D : public csSparse3D
00062 {
00063 private:
00065   struct SparseCell
00066   {
00067     int z;
00068     void* obj;
00069     SparseCell* next, * prev;
00070   };
00072   struct HdY
00073   {
00074     HdY () { first_z = NULL; }
00075     int y;
00076     HdY* next, * prev;
00077     SparseCell* first_z;
00078   };
00080   struct HdX
00081   {
00082     HdX () { first_y = NULL; }
00083     int x;
00084     HdX* next, * prev;
00085     HdY* first_y;
00086   };
00087 
00089   HdX* first_x;
00091   HdX* get_header_x (int x);
00093   HdY* get_header_y (HdX* y_list, int y);
00095   SparseCell* get_cell_z (HdY* z_list, int z);
00096 
00097 public:
00099   csWideSparse3D ();
00101   virtual ~csWideSparse3D ();
00102 
00104   virtual void Clear ();
00105 
00107   virtual void Set (int x, int y, int z, void* obj);
00108 
00110   virtual void* Get (int x, int y, int z);
00111 
00113   virtual void Del (int x, int y, int z);
00114 };
00115 
00116 #endif // __SPARSE3D_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000