1 #ifndef SPARSE_VECTOR_HH 2 #define SPARSE_VECTOR_HH 80 typename map_t::const_iterator it = m_->
the_map_.find(k_);
100 const_iterator it = m_->
the_map_.find(k_);
128 typename map_t::iterator it = m_->
the_map_.find(k_);
132 m_->
the_map_.insert(
typename map_t::value_type(k_,x));
167 const_iterator it = the_map_.find(
key_t(i));
168 if ( it == the_map_.end() )
187 set(size_type i,
const value_t &val) {
188 typename map_t::iterator it = the_map_.find(
key_t(i));
189 if ( it != the_map_.end() ) {
192 the_map_.insert(
typename map_t::value_type(
key_t(i),val));
203 typename map_t::iterator it = the_map_.find(
key_t(i));
204 if ( it != the_map_.end() ) {
205 the_map_.erase(
key_t(i));
215 return the_map_.size();
225 return the_map_.empty();
244 return the_map_.begin();
253 const_iterator
end()
const {
254 return the_map_.end();
270 operator <<(std::ostream &out, const SparseVector<T> &v) {
274 out <<it->first <<
":" << it->second <<
" ";
282 #endif // SPARSE_VECTOR_HH const_iterator end() const
End const iterator over vector entries.
Definition: sparse_vector.hh:253
void reset(size_type i)
Set vector entry to default value.
Definition: sparse_vector.hh:202
size_t size_type
usual definition of size_type
Definition: sparse_vector.hh:30
bool empty() const
Check for emptiness.
Definition: sparse_vector.hh:224
element operator+=(const value_t &x)
Operator for in place addition.
Definition: sparse_vector.hh:99
SparseVector(const value_t &def)
Construct with default value.
Definition: sparse_vector.hh:146
const_iterator begin() const
Begin const iterator over vector entries.
Definition: sparse_vector.hh:243
element operator[](size_type i)
Access to vector element.
Definition: sparse_vector.hh:155
Definition: aligner.cc:17
value_t def_
default value of vector entries
Definition: sparse_vector.hh:38
map_t the_map_
internal representation of sparse vector
Definition: sparse_vector.hh:37
map_t::const_iterator const_iterator
Stl-compatible constant iterator over vector elements.
Definition: sparse_vector.hh:47
size_type key_t
type of vector index pair
Definition: sparse_vector.hh:32
Element of sparse vector.
Definition: sparse_vector.hh:58
Represents a sparse vector.
Definition: sparse_vector.hh:25
void clear()
Clear the vector.
Definition: sparse_vector.hh:232
unordered_map< key_t, value_t >::type map_t
map type
Definition: sparse_vector.hh:36
T value_t
type of vector entries
Definition: sparse_vector.hh:28
element & operator=(const value_t &x)
Assignment operator.
Definition: sparse_vector.hh:121
size_type size() const
Size of sparse vector.
Definition: sparse_vector.hh:214
element(SparseVector< T > *m, key_t k)
Construct as proxy for specified element in given sparse vector.
Definition: sparse_vector.hh:70