1 #ifndef _snl_fei_MapContig_hpp_
2 #define _snl_fei_MapContig_hpp_
12 #include <fei_macros.hpp>
18 template<
typename VAL_TYPE>
46 :
offset_(offset), mapPtr_(mapPtr)
56 if (!mapPtr_)
return(*
this);
57 int len = mapPtr_->len_;
58 int* keysPtr = mapPtr_->keysPtr_;
59 int first = mapPtr_->first_;
63 if (keysPtr[
offset_] >= first)
break;
96 mapPtr_ = src.mapPtr_;
129 std::vector<int> keys_;
132 std::vector<VAL_TYPE> values_;
133 VAL_TYPE* valuesPtr_;
138 template<
typename VAL_TYPE>
140 : keys_(lastKey-firstKey+1),
142 values_(lastKey-firstKey+1),
144 len_(lastKey-firstKey+1)
146 keysPtr_ = keys_.size()>0 ? &keys_[0] : NULL;
147 for(
int i=0; i<len_; ++i) {
148 keysPtr_[i] = firstKey+i;
150 valuesPtr_ = values_.size()>0 ? &values_[0] : NULL;
155 template<
typename VAL_TYPE>
159 values_(src.values_),
163 keysPtr_ = keys_.size()>0 ? &keys_[0] : NULL;
164 valuesPtr_ = values_.size()>0 ? &values_[0] : NULL;
168 template<
typename VAL_TYPE>
173 template<
typename VAL_TYPE>
179 template<
typename VAL_TYPE>
185 template<
typename VAL_TYPE>
186 inline std::pair<typename MapContig<VAL_TYPE>::iterator,
bool>
189 int localkey = val.first - first_;
190 if (localkey < 0 || localkey >= len_) {
191 return( std::pair<iterator,bool>(m_end_,
false) );
194 valuesPtr_[localkey] = val.second;
196 return( std::pair<iterator,bool>(iterator(localkey,
this),
true));
199 template<
typename VAL_TYPE>
200 inline typename MapContig<VAL_TYPE>::iterator
202 typename MapContig<VAL_TYPE>::value_type val)
204 int offset = pos.offset_;
205 if (offset < 0 || offset >=len_ || pos == m_end_) {
206 offset = val.first - first_;
207 if (offset < 0 || offset >= len_) {
212 valuesPtr_[offset] = val.second;
214 return( iterator(offset,
this) );
217 template<
typename VAL_TYPE>
220 int localkey = key - first_;
221 if (localkey < 0 || localkey >= len_) {
228 template<
typename VAL_TYPE>
231 int localkey = key - first_;
232 if (localkey < 0 || localkey >= len_) {
239 template<
typename VAL_TYPE>
std::pair< int, VAL_TYPE > value_type
iterator(int offset, MapContig< VAL_TYPE > *mapPtr)
std::pair< iterator, bool > insert(value_type val)
iterator & operator=(const iterator &src)
bool operator==(const iterator &rhs)
iterator lower_bound(int key)
bool operator!=(const iterator &rhs)
MapContig(int firstKey, int lastKey)