FEI Version of the Day
snl_fei_RaggedTable_specialize.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 #ifndef _snl_fei_RaggedTable_specialize_hpp_
00044 #define _snl_fei_RaggedTable_specialize_hpp_
00045 
00046 
00047 #include <fei_macros.hpp>
00048 #include <snl_fei_RaggedTable.hpp>
00049 #include <fei_ctg_set.hpp>
00050 #include <snl_fei_MapContig.hpp>
00051 
00052 namespace snl_fei {
00053 
00055 template<>
00056 class RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >
00057   : public fei::IndexTable {
00058 public:
00059   RaggedTable(int firstKey, int lastKey);
00060 
00061   RaggedTable(const RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >& src);
00062 
00063   typedef MapContig<fei::ctg_set<int>*> map_type;
00064   typedef fei::ctg_set<int> row_type;
00065   typedef map_type::iterator iterator;
00066 
00067   virtual ~RaggedTable()
00068   {
00069     iterator it = begin();
00070     iterator it_end = end();
00071     for(; it!=it_end; ++it) {
00072       poolAllocatorSet_.destroy( (*it).second );
00073       poolAllocatorSet_.deallocate( (*it).second, 1 );
00074     }
00075   }
00076 
00077   void addDiagonals(int numIndices,
00078                     const int* indices);
00079 
00080   void addIndices(int row,
00081                   int numIndices,
00082                   const int* indices);
00083 
00084   void addIndices(int numRows,
00085                   const int* rows,
00086                   int numIndices,
00087                   const int* indices);
00088 
00089   map_type& getMap() { return( map_ ); }
00090 
00091   row_type* getRow(int row)
00092   {
00093     iterator m_end = map_.end();
00094     iterator m_iter = map_.find(row);
00095     return( m_end == m_iter ? NULL : (*m_iter).second );
00096   }
00097 
00098   iterator begin() { return( map_.begin() ); }
00099 
00100   iterator end() { return( map_.end() ); }
00101 
00102  private:
00103   map_type map_;
00104   fei_Pool_alloc<row_type> poolAllocatorSet_;
00105   row_type dummy;
00106 };//RaggedTable<MapContig<fei::ctg_set<int>*> >
00107 
00108 }//namespace snl_fei
00109 #endif
00110 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends