CrystalSpace

Public API Reference

csutil/sparse3d.h

Go to the documentation of this file.
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 __CS_SPARSE3D_H__
00021 #define __CS_SPARSE3D_H__
00022 
00027 #include "csextern.h"
00028 
00033 class CS_CRYSTALSPACE_EXPORT csSparse3D
00034 {
00035 public:
00037   csSparse3D () { }
00039   virtual ~csSparse3D () { }
00040 
00042   virtual void Clear () = 0;
00043 
00045   virtual void Set (int x, int y, int z, void* obj) = 0;
00046 
00048   virtual void* Get (int x, int y, int z) = 0;
00049 
00051   virtual void Del (int x, int y, int z) = 0;
00052 };
00053 
00067 class CS_CRYSTALSPACE_EXPORT csWideSparse3D : public csSparse3D
00068 {
00069 private:
00071   struct SparseCell
00072   {
00073     int z;
00074     void* obj;
00075     SparseCell* next, * prev;
00076   };
00078   struct HdY
00079   {
00080     HdY () { first_z = 0; }
00081     int y;
00082     HdY* next, * prev;
00083     SparseCell* first_z;
00084   };
00086   struct HdX
00087   {
00088     HdX () { first_y = 0; }
00089     int x;
00090     HdX* next, * prev;
00091     HdY* first_y;
00092   };
00093 
00095   HdX* first_x;
00097   HdX* get_header_x (int x);
00099   HdY* get_header_y (HdX* y_list, int y);
00101   SparseCell* get_cell_z (HdY* z_list, int z);
00102 
00103 public:
00105   csWideSparse3D ();
00107   virtual ~csWideSparse3D ();
00108 
00110   virtual void Clear ();
00111 
00113   virtual void Set (int x, int y, int z, void* obj);
00114 
00116   virtual void* Get (int x, int y, int z);
00117 
00119   virtual void Del (int x, int y, int z);
00120 };
00121 
00122 #endif // __CS_SPARSE3D_H__

Generated for Crystal Space by doxygen 1.4.7