Main Page   Namespace List   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Sparsevec.hh

Go to the documentation of this file.
00001 #ifndef SPARSEVEC_TMPL_HEADER
00002 #define SPARSEVEC_TMPL_HEADER
00003 
00004 // ==== TEMPLATE HEADER Sparsevec.hh ====
00005 
00013 // ---- COMPATIBILITY NOTE ----
00014 
00015 // This class depends on the Standard Template Library.
00016 
00017 // ---- STANDARD HEADERS ----
00018 
00019 #ifdef _STANDARD_C_PLUS_PLUS
00020 #include <map>
00021 using namespace std;
00022 #else
00023 #include <map.h>
00024 #endif
00025 
00026 // ==== CLASSES ====
00027 
00028 namespace RazorBack {
00029 
00036 template <class T_>
00037 class Sparsevec_
00038 {
00039     // data
00040     private:
00041             
00042     static const T_ NULLITEM;   //< to be returned by const accesses
00043     map<size_t, T_> Data;   //< the non-0 elements keyed by their index
00044     
00045     // methods
00046     public:
00047     
00049     Sparsevec_(): Data() {}
00050     
00052     const T_& get_item(size_t Idx) const;
00053     
00058     bool set_item(size_t Idx, const T_& Val);
00059     
00061     void clear() { Data.erase(Data.begin(), Data.end()); }  // clear() not in SGI STL
00062 
00064     bool empty() const { return Data.empty(); }
00065     
00066     protected:
00067             
00068     const map<size_t, T_>& data() const { return Data; }
00069     
00070 };
00071 // END OF CLASS Sparsevec_
00072 
00073 } // RazorBack
00074 
00075 // ==== END OF TEMPLATE HEADER Sparsevec.hh ====
00076 
00077 #ifdef INCLUDE_TMPL_DEFS
00078 #include "Sparsevec.cc"
00079 #endif
00080 
00081 #endif  // SPARSEVEC_TMPL_HEADER

Generated at Wed Aug 21 09:33:40 2002 for The Razorback C++ Library: Miscellaneous by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001