LCOV - code coverage report
Current view: top level - sc/inc - fstalgorithm.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 13 0.0 %
Date: 2014-04-14 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef SC_FSTALGORITHM_HXX
      11             : #define SC_FSTALGORITHM_HXX
      12             : 
      13             : #include <mdds/flat_segment_tree.hpp>
      14             : #include <vector>
      15             : 
      16             : namespace sc {
      17             : 
      18             : /**
      19             :  * Convert a flat_segment_tree structure whose value type is boolean, into
      20             :  * an array of ranges that corresponds with the segments that have a 'true'
      21             :  * value.
      22             :  */
      23             : template<typename _Key, typename _Span>
      24           0 : std::vector<_Span> toSpanArray( const mdds::flat_segment_tree<_Key,bool>& rTree )
      25             : {
      26             :     typedef mdds::flat_segment_tree<_Key,bool> FstType;
      27             : 
      28           0 :     std::vector<_Span> aSpans;
      29             : 
      30           0 :     typename FstType::const_iterator it = rTree.begin(), itEnd = rTree.end();
      31           0 :     _Key nLastPos = it->first;
      32           0 :     bool bLastVal = it->second;
      33           0 :     for (++it; it != itEnd; ++it)
      34             :     {
      35           0 :         _Key nThisPos = it->first;
      36           0 :         bool bThisVal = it->second;
      37             : 
      38           0 :         if (bLastVal)
      39           0 :             aSpans.push_back(_Span(nLastPos, nThisPos-1));
      40             : 
      41           0 :         nLastPos = nThisPos;
      42           0 :         bLastVal = bThisVal;
      43             :     }
      44             : 
      45           0 :     return aSpans;
      46             : }
      47             : 
      48             : }
      49             : 
      50             : #endif
      51             : 
      52             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10