1 #ifndef _snl_fei_RaggedTable_hpp_
2 #define _snl_fei_RaggedTable_hpp_
12 #include <fei_macros.hpp>
14 #include <snl_fei_SetTraits_specialize.hpp>
15 #include <snl_fei_MapTraits_specialize.hpp>
17 #include <fei_IndexTable.hpp>
18 #include <fei_Pool_alloc.hpp>
28 template<
typename MAP_TYPE,
typename SET_TYPE>
65 const MAP_TYPE&
getMap()
const;
89 template<
typename MAP_TYPE,
typename SET_TYPE>
98 template<
typename MAP_TYPE,
typename SET_TYPE>
105 template<
typename MAP_TYPE,
typename SET_TYPE>
108 iterator it = begin();
109 iterator it_end = end();
110 for(; it!=it_end; ++it) {
111 poolAllocatorSet_.destroy( it->second );
112 poolAllocatorSet_.deallocate( it->second, 1 );
116 template<
typename MAP_TYPE,
typename SET_TYPE>
124 SET_TYPE* mapped_indices = NULL;
126 bool found_row =
false;
127 if (m_iter != m_end) {
128 if ((*m_iter).first == row) {
129 mapped_indices = (*m_iter).second;
135 mapped_indices = poolAllocatorSet_.allocate(1);
136 poolAllocatorSet_.construct(mapped_indices, dummy);
137 typename MAP_TYPE::value_type val(row, mapped_indices);
141 for(
int i=0; i<numIndices; ++i) {
146 template<
typename MAP_TYPE,
typename SET_TYPE>
154 SET_TYPE* mapped_indices = NULL;
156 for(
int i=0; i<numRows; ++i) {
160 bool found_row =
false;
161 if (m_iter != m_end) {
162 const typename MAP_TYPE::value_type& m_pair = *m_iter;
163 if (m_pair.first == row) {
164 mapped_indices = m_pair.second;
170 mapped_indices = poolAllocatorSet_.allocate(1);
171 poolAllocatorSet_.construct(mapped_indices, dummy);
172 typename MAP_TYPE::value_type val(row, mapped_indices);
176 for(
int j=0; j<numIndices; ++j) {
182 template<
typename MAP_TYPE,
typename SET_TYPE>
188 template<
typename MAP_TYPE,
typename SET_TYPE>
194 template<
typename MAP_TYPE,
typename SET_TYPE>
200 return( m_end == m_iter ? NULL : (*m_iter).second );
203 template<
typename MAP_TYPE,
typename SET_TYPE>
207 return(map_.begin());
210 template<
typename MAP_TYPE,
typename SET_TYPE>
217 template<
typename MAP_TYPE,
typename SET_TYPE>
221 for(
int i=0; i<numIndices; ++i) {
222 int ind = indices[i];
223 addIndices(ind, 1, &ind);
227 template<
typename MAP_TYPE,
typename SET_TYPE>
230 if (map_.size() != rhs.
getMap().size()) {
232 FEI_COUT <<
"RaggedTable::equal sizes don't match." << FEI_ENDL;
237 typename map_type::const_iterator
238 m_iter = map_.begin(),
241 typename map_type::const_iterator
242 rhs_iter = rhs.
getMap().begin(),
243 rhs_end = rhs.
getMap().end();
245 for(; m_iter != m_end; ++m_iter, ++rhs_iter) {
246 if (rhs_iter->first != m_iter->first) {
248 FEI_COUT <<
"RaggedTable::equal keys don't match." << FEI_ENDL;
253 if (*(rhs_iter->second) != *(m_iter->second)) {
255 FEI_COUT <<
"RaggedTable::equal row-values don't match." << FEI_ENDL;
static void insert(MAP_TYPE &map_obj, typename MAP_TYPE::iterator &pos, typename MAP_TYPE::value_type &val)
void addDiagonals(int numIndices, const int *indices)
RaggedTable(int firstKey, int lastKey)
static MAP_TYPE::iterator lower_bound(MAP_TYPE &map_obj, typename MAP_TYPE::key_type item)
SET_TYPE * getRow(int row)
static void insert(SET_TYPE *set_obj, typename SET_TYPE::key_type item)
MAP_TYPE::iterator iterator
void addIndices(int row, int numIndices, const int *indices)
bool equal(const RaggedTable< MAP_TYPE, SET_TYPE > &rhs, bool quiet=true) const