FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
snl_fei_RaggedTable_specialize.cpp
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #include <fei_macros.hpp>
10 #include <snl_fei_RaggedTable_specialize.hpp>
11 
12 namespace snl_fei {
13 
15 RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::RaggedTable(int firstKey, int lastKey)
16  : map_(firstKey, lastKey),
17  poolAllocatorSet_(),
18  dummy()
19 {
20  int len = lastKey-firstKey+1;
21  if (len > 0) {
22  map_type::value_type val;
23  for(int i=0; i<len; ++i) {
24  val.first = firstKey+i;
25  row_type* row = poolAllocatorSet_.allocate(1);
26  poolAllocatorSet_.construct(row,dummy);
27  val.second = row;
28  map_.insert(val);
29  }
30  }
31 }
32 
33 RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::RaggedTable(const RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >& src)
34  : map_(src.map_),
35  poolAllocatorSet_()
36 {
37 }
38 
39 void RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::addIndices(int row,
40  int numIndices,
41  const int* indices)
42 {
43  iterator m_end = map_.end();
44  iterator m_iter = map_.lower_bound(row);
45 
46  map_type::mapped_type mapped_indices = (*m_iter).second;
47 
48  if (mapped_indices == NULL) {
49  throw std::runtime_error("RaggedTable<MapContig>, NULL row.");
50  }
51 
52  for(int i=0; i<numIndices; ++i) {
53  mapped_indices->insert2(indices[i]);
54  }
55 }
56 
57 void
58 RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::addIndices(int numRows,
59  const int* rows,
60  int numIndices,
61  const int* indices)
62 {
63  iterator m_end = map_.end();
64  map_type::mapped_type mapped_indices = NULL;
65 
66  for(int i=0; i<numRows; ++i) {
67  int row = rows[i];
68  iterator m_iter = map_.lower_bound(row);
69 
70  mapped_indices = (*m_iter).second;
71  if (mapped_indices == NULL) {
72  throw std::runtime_error("RaggedTable<MapContig>, NULL row.");
73  }
74 
75  for(int j=0; j<numIndices; ++j) {
76  mapped_indices->insert2(indices[j]);
77  }
78  }
79 }
80 
81 void RaggedTable<MapContig<fei::ctg_set<int>*>,fei::ctg_set<int> >::addDiagonals(int numIndices,
82  const int* indices)
83 {
84  for(int i=0; i<numIndices; ++i) {
85  int ind = indices[i];
86  addIndices(ind, 1, &ind);
87  }
88 }
89 
90 }//namespace snl_fei
91 
static const_iterator end()