42 _indices.reserve(size);
51 {
return _indices.empty(); }
55 {
return _indices.size(); }
60 dolfin_assert(index < _size);
61 return _has_index[index];
65 std::size_t
find(std::size_t index)
const 67 dolfin_assert(index < _size);
68 if (!_has_index[index])
70 "locate position of index",
71 "Index %d is not in index set", index);
72 return _positions[index];
78 dolfin_assert(i < _indices.size());
85 dolfin_assert(i < _indices.size());
92 dolfin_assert(index < _size);
93 if (_has_index[index])
95 _indices.push_back(index);
96 _has_index[index] =
true;
97 _positions[index] = _indices.size() - 1;
104 for (std::size_t i = 0; i < _size; i++)
105 _indices.push_back(i);
106 std::fill(_has_index.begin(), _has_index.end(),
true);
113 std::fill(_has_index.begin(), _has_index.end(),
false);
114 std::fill(_positions.begin(), _positions.end(), 0);
123 std::vector<std::size_t> _indices;
126 std::vector<std::size_t> _has_index;
129 std::vector<std::size_t> _positions;
IndexSet(std::size_t size)
Create index set of given size.
Definition: IndexSet.h:39
void clear()
Clear set.
Definition: IndexSet.h:110
Definition: IndexSet.h:34
std::size_t size() const
Return size of set.
Definition: IndexSet.h:54
std::size_t find(std::size_t index) const
Return position (if any) for given index.
Definition: IndexSet.h:65
void fill()
Fill index set with indices 0, 1, 2, ..., size - 1.
Definition: IndexSet.h:101
void insert(std::size_t index)
Insert index into set.
Definition: IndexSet.h:90
std::size_t & operator[](std::size_t i)
Return given index.
Definition: IndexSet.h:76
bool has_index(std::size_t index) const
Check whether index is in set.
Definition: IndexSet.h:58
bool empty() const
Return true if set is empty.
Definition: IndexSet.h:50
void dolfin_error(std::string location, std::string task, std::string reason,...)
Definition: log.cpp:129
~IndexSet()
Destructor.
Definition: IndexSet.h:47