source: trunk/lib/Vector.cc @ 1208

Last change on this file since 1208 was 1208, checked in by Peter Johansson, 12 years ago

Changed value type of SparseVector? to be (signed) int. Use
Vector::iterator when printing Vector's data instead of using
operator[]
refs #475

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1// $Id: Vector.cc 1208 2010-10-07 03:33:36Z peter $
2
3/*
4  Copyright (C) 2010 Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "Vector.h"
23
24namespace theplu{
25namespace svndigest{
26
27
28  void accumulate(const SparseVector& vec, SumVector& result)
29  {
30    result.clear();
31    int value = 0;
32    for (SparseVector::const_iterator iter = vec.begin(); 
33         iter!=vec.end();++iter) {
34      value += iter->second;
35      assert(value>=0);
36      result.set(iter->first, value);
37    }
38  }
39
40}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.