snl_fei_RaggedTable_specialize.cpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #include <fei_macros.hpp>
00010 #include <snl_fei_RaggedTable_specialize.hpp>
00011 
00012 namespace snl_fei {
00013 
00015 RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::RaggedTable(int firstKey, int lastKey)
00016   : map_(firstKey, lastKey),
00017     poolAllocatorSet_(),
00018     dummy()
00019 {
00020   int len = lastKey-firstKey+1;
00021   if (len > 0) {
00022     map_type::value_type val;
00023     for(int i=0; i<len; ++i) {
00024       val.first = firstKey+i;
00025       row_type* row = poolAllocatorSet_.allocate(1);
00026       poolAllocatorSet_.construct(row,dummy);
00027       val.second = row;
00028       map_.insert(val);
00029     }
00030   }
00031 }
00032 
00033 RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::RaggedTable(const RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >& src)
00034  : map_(src.map_),
00035    poolAllocatorSet_()
00036 {
00037 }
00038 
00039 void RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::addIndices(int row,
00040                              int numIndices,
00041                              const int* indices)
00042 {
00043   iterator m_end = map_.end();
00044   iterator m_iter = map_.lower_bound(row);
00045 
00046   map_type::mapped_type mapped_indices = (*m_iter).second;
00047 
00048   if (mapped_indices == NULL) {
00049     throw std::runtime_error("RaggedTable<MapContig>, NULL row.");
00050   }
00051 
00052   for(int i=0; i<numIndices; ++i) {
00053     mapped_indices->insert2(indices[i]);
00054   }
00055 }
00056 
00057 void
00058 RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::addIndices(int numRows,
00059                              const int* rows,
00060                              int numIndices,
00061                              const int* indices)
00062 {
00063   iterator m_end = map_.end();
00064   map_type::mapped_type mapped_indices = NULL;
00065 
00066   for(int i=0; i<numRows; ++i) {
00067     int row = rows[i];
00068     iterator m_iter = map_.lower_bound(row);
00069 
00070     mapped_indices = (*m_iter).second;
00071     if (mapped_indices == NULL) {
00072       throw std::runtime_error("RaggedTable<MapContig>, NULL row.");
00073     }
00074 
00075     for(int j=0; j<numIndices; ++j) {
00076       mapped_indices->insert2(indices[j]);
00077     }
00078   }
00079 }
00080 
00081 void RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::addDiagonals(int numIndices,
00082                                                          const int* indices)
00083 {
00084   for(int i=0; i<numIndices; ++i) {
00085     int ind = indices[i];
00086     addIndices(ind, 1, &ind);
00087   }
00088 }
00089 
00090 }//namespace snl_fei
00091 

Generated on Tue Jul 13 09:27:46 2010 for FEI by  doxygen 1.4.7