~corrado-maurini/dolfin/tao

« back to all changes in this revision

Viewing changes to dolfin/common/RangedIndexSet.h

  • Committer: corrado maurini
  • Date: 2012-12-18 12:16:08 UTC
  • mfrom: (6685.78.207 trunk)
  • Revision ID: corrado.maurini@upmc.fr-20121218121608-nk82ly9jgsld9u84
updating with trunk, fix uint in TAO solver and hacking the check for tao FindTAO.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
  public:
41
41
 
42
42
    /// Create a ranged set with range given as a (lower, upper) pair.
43
 
    RangedIndexSet(std::pair<uint, uint> range)
 
43
    RangedIndexSet(std::pair<std::size_t, std::size_t> range)
44
44
      : _range(range), _is_set(range.second - range.first)
45
45
    {
46
46
      clear();
47
47
    }
48
48
 
49
49
    /// Create a ranged set with 0 as lower range
50
 
    RangedIndexSet(uint upper_range)
51
 
      : _range(std::pair<uint, uint>(0, upper_range)), _is_set(upper_range)
 
50
    RangedIndexSet(std::size_t upper_range)
 
51
      : _range(std::pair<std::size_t, std::size_t>(0, upper_range)), _is_set(upper_range)
52
52
    {
53
53
      clear();
54
54
    }
55
55
 
56
56
    /// Return true if a given index is within range, i.e., if it can be stored in the set.
57
 
    bool in_range(uint i) const
 
57
    bool in_range(std::size_t i) const
58
58
    {
59
59
      return (i >= _range.first && i < _range.second);
60
60
    }
61
61
 
62
62
    /// Check is the set contains the given index.
63
 
    bool has_index(uint i) const
 
63
    bool has_index(std::size_t i) const
64
64
    {
65
65
      dolfin_assert(in_range(i));
66
66
      return _is_set[i - _range.first];
68
68
 
69
69
    /// Insert a given index into the set. Returns true if the index was
70
70
    /// inserted (i.e., the index was not already in the set).
71
 
    bool insert(uint i)
 
71
    bool insert(std::size_t i)
72
72
    {
73
73
      dolfin_assert(in_range(i));
74
74
      std::vector<bool>::reference entry = _is_set[i - _range.first];
84
84
    }
85
85
 
86
86
    /// Erase an index from the set.
87
 
    void erase(uint i)
 
87
    void erase(std::size_t i)
88
88
    {
89
89
      dolfin_assert(in_range(i));
90
90
      _is_set[i - _range.first] = false;
98
98
 
99
99
  private:
100
100
 
101
 
    const std::pair<uint, uint> _range;
 
101
    const std::pair<std::size_t, std::size_t> _range;
102
102
    std::vector<bool> _is_set;
103
103
 
104
104
  };