Public Types | Public Member Functions | Public Attributes | List of all members
IndexRangeGroup Class Reference

#include <IndexRangeGroup.h>

Public Types

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using Name = std::string
 
using NameVector = std::vector< Name >
 
using RangeVector = std::vector< IndexRange >
 

Public Member Functions

 IndexRangeGroup ()
 
 IndexRangeGroup (Name a_name, const NameVector &a_labels, const RangeVector &a_ranges)
 
 IndexRangeGroup (Name a_name, const RangeVector &a_ranges)
 
 IndexRangeGroup (const IndexRange &ran)
 
 IndexRangeGroup (std::string sgrp)
 
Index size () const
 
bool operator< (const IndexRangeGroup &rhs) const
 
bool isValid () const
 
IndexRange range (Index iran) const
 
IndexRange range (Name name) const
 
Name label (Index ilab=0) const
 
void getIndices (IndexVector &idxs) const
 

Public Attributes

Name name
 
NameVector labels
 
RangeVector ranges
 

Detailed Description

Definition at line 20 of file IndexRangeGroup.h.

Member Typedef Documentation

using IndexRangeGroup::Index = unsigned int

Definition at line 24 of file IndexRangeGroup.h.

Definition at line 25 of file IndexRangeGroup.h.

Definition at line 26 of file IndexRangeGroup.h.

Definition at line 27 of file IndexRangeGroup.h.

Definition at line 28 of file IndexRangeGroup.h.

Constructor & Destructor Documentation

IndexRangeGroup::IndexRangeGroup ( )
inline

Definition at line 36 of file IndexRangeGroup.h.

36 { };
IndexRangeGroup::IndexRangeGroup ( Name  a_name,
const NameVector a_labels,
const RangeVector a_ranges 
)
inline

Definition at line 39 of file IndexRangeGroup.h.

40  : name(a_name), labels(a_labels), ranges(a_ranges) { }
RangeVector ranges
NameVector labels
IndexRangeGroup::IndexRangeGroup ( Name  a_name,
const RangeVector a_ranges 
)
inline

Definition at line 43 of file IndexRangeGroup.h.

44  : name(a_name), ranges(a_ranges) { }
RangeVector ranges
IndexRangeGroup::IndexRangeGroup ( const IndexRange ran)
inlineexplicit

Definition at line 47 of file IndexRangeGroup.h.

48  : name(ran.name), labels(ran.labels), ranges(1, ran) { }
NameVector labels
Definition: IndexRange.h:33
Name name
Definition: IndexRange.h:32
RangeVector ranges
NameVector labels
IndexRangeGroup::IndexRangeGroup ( std::string  sgrp)
inlineexplicit

Definition at line 52 of file IndexRangeGroup.h.

52  {
53  std::string srem = sgrp;
54  std::string::size_type ipos = srem.find(",");
55  if ( ipos == std::string::npos ) {
56  IndexRange ran(srem);
57  *this = IndexRangeGroup(ran);
58  return;
59  }
60  std::string nameTmp = srem.substr(0, ipos);
61  while ( ipos != std::string::npos ) {
62  srem = srem.substr(ipos+1);
63  ipos = srem.find(",");
64  std::string sran = srem.substr(0, ipos);
65  IndexRange ran(sran);
66  if ( ! ran.isValid() ) return;
67  ranges.push_back(ran);
68  }
69  }
std::string string
Definition: nybbler.cc:12

Member Function Documentation

void IndexRangeGroup::getIndices ( IndexVector idxs) const
inline

Definition at line 94 of file IndexRangeGroup.h.

94  {
95  for ( const IndexRange& ran : ranges ) {
96  for ( Index ival=ran.begin; ival<ran.end; ++ival ) idxs.push_back(ival);
97  }
98  }
unsigned int Index
bool IndexRangeGroup::isValid ( ) const
inline

Definition at line 78 of file IndexRangeGroup.h.

78 { return name.size() || ranges.size(); }
Name IndexRangeGroup::label ( Index  ilab = 0) const
inline

Definition at line 89 of file IndexRangeGroup.h.

89  {
90  if ( ilab >= labels.size() ) return "";
91  return labels[ilab];
92  }
NameVector labels
bool IndexRangeGroup::operator< ( const IndexRangeGroup rhs) const
inline

Definition at line 75 of file IndexRangeGroup.h.

75 { return name < rhs.name; }
IndexRange IndexRangeGroup::range ( Index  iran) const
inline

Definition at line 79 of file IndexRangeGroup.h.

79  {
80  if ( iran >= size() ) return IndexRange();
81  return ranges[iran];
82  }
Index size() const
IndexRange IndexRangeGroup::range ( Name  name) const
inline

Definition at line 83 of file IndexRangeGroup.h.

83  {
84  for ( const IndexRange& ran : ranges ) {
85  if ( ran.name == name ) return ran;
86  }
87  return IndexRange();
88  }
Index IndexRangeGroup::size ( ) const
inline

Definition at line 72 of file IndexRangeGroup.h.

72 { return ranges.size(); }

Member Data Documentation

NameVector IndexRangeGroup::labels

Definition at line 32 of file IndexRangeGroup.h.

Name IndexRangeGroup::name

Definition at line 31 of file IndexRangeGroup.h.

RangeVector IndexRangeGroup::ranges

Definition at line 33 of file IndexRangeGroup.h.


The documentation for this class was generated from the following file: