24 #ifndef PPL_Sparse_Row_inlines_hh
25 #define PPL_Sparse_Row_inlines_hh 1
45 : tree(y.tree), size_(y.size_) {
51 std::distance(y.begin(), y.lower_bound(
std::min(y.size(), sz)))),
86 PPL_ASSERT(
size() >= n);
92 PPL_ASSERT(
size() <= n);
98 PPL_ASSERT(i <
size_);
106 PPL_ASSERT(i <=
size_);
154 PPL_ASSERT(i <
size_);
159 inline Coefficient_traits::const_reference
164 inline Coefficient_traits::const_reference
166 PPL_ASSERT(i <
size_);
181 PPL_ASSERT(i <
size());
185 if (itr !=
end() && itr.
index() == i) {
193 PPL_ASSERT(i <
size());
197 if (itr !=
end() && itr.
index() == i) {
205 PPL_ASSERT(i <
size());
209 if (itr !=
end() && itr.
index() == i) {
218 PPL_ASSERT(i <
size());
222 if (itr !=
end() && itr.
index() == i) {
230 PPL_ASSERT(i <=
size());
238 if (itr.
index() < i) {
242 PPL_ASSERT(itr ==
end() || itr.
index() >= i);
249 PPL_ASSERT(i <=
size());
257 if (itr.
index() < i) {
261 PPL_ASSERT(itr ==
end() || itr.
index() >= i);
268 PPL_ASSERT(i <=
size());
276 if (itr.
index() < i) {
280 PPL_ASSERT(itr ==
end() || itr.
index() >= i);
287 PPL_ASSERT(i <=
size());
295 if (itr.
index() < i) {
299 PPL_ASSERT(itr ==
end() || itr.
index() >= i);
306 PPL_ASSERT(i <
size_);
312 Coefficient_traits::const_reference x) {
313 PPL_ASSERT(i <
size_);
319 PPL_ASSERT(i <
size_);
325 PPL_ASSERT(i <
size_);
331 PPL_ASSERT(i !=
end());
332 PPL_ASSERT(j !=
end());
341 PPL_ASSERT(itr !=
end());
355 PPL_ASSERT(i <
size());
381 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
383 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
391 #endif // !defined(PPL_Sparse_Row_inlines_hh)
dimension_type index() const
Returns the index of the element pointed to by *this.
void increase_keys_from(dimension_type key, dimension_type n)
Adds n to all keys greater than or equal to key.
iterator find(dimension_type i)
Looks for an element with index i.
void delete_element_and_shift(dimension_type i)
Deletes the i-th element from the row, shifting the next elements to the left.
void reset_after(dimension_type i)
Resets to zero the elements with index greater than or equal to i.
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type size() const
Returns the size of the row.
void m_swap(Sparse_Row &x)
Swaps *this and x.
void resize(dimension_type n)
Resizes the row to the specified size.
iterator reset(iterator i)
Resets to zero the value pointed to by i.
iterator begin()
Returns an iterator that points at the first element.
A finite sparse sequence of coefficients.
The standard C++ namespace.
An iterator on the tree elements, ordered by key.
Sparse_Row(dimension_type n=0)
Constructs a row with the specified size.
const iterator & end()
Returns an iterator that points after the last stored element.
static dimension_type max_size()
Returns the size() of the largest possible CO_Tree.
dimension_type size() const
Returns the number of elements stored in the tree.
const iterator & end()
Returns an iterator that points after the last element.
bool empty() const
Returns true if the tree has no elements.
iterator insert(dimension_type key)
Inserts an element in the tree.
void expand_within_capacity(dimension_type n)
Resizes the row to size n.
Coefficient & operator[](dimension_type i)
Gets a reference to the i-th element.
const_iterator cbegin() const
Returns a const_iterator that points at the first element.
void clear()
Resets all the elements of this row.
void shrink(dimension_type n)
Resizes the row to size n.
void fast_swap(dimension_type i, iterator itr)
iterator bisect(dimension_type key)
Searches an element with key key using bisection.
const const_iterator & cend() const
Returns a const_iterator that points after the last element.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
memory_size_type total_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
CO_Tree tree
The tree used to store the elements.
iterator insert(dimension_type i, Coefficient_traits::const_reference x)
Equivalent to (*this)[i] = x; find(i), but faster.
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
The entire library is confined to this namespace.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
A const iterator on the tree elements, ordered by key.
iterator lower_bound(dimension_type i)
Lower bound of index i.
void swap_coefficients(dimension_type i, dimension_type j)
Swaps the i-th element with the j-th element.
void clear()
Removes all elements from the tree.
dimension_type size_
The size of the row.
dimension_type num_stored_elements() const
Returns the number of elements explicitly stored in the row.
iterator begin()
Returns an iterator that points at the first stored element.
const const_iterator & cend() const
Returns an iterator that points after the last element.
void swap(Sparse_Row &x, Sparse_Row &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
iterator erase(dimension_type key)
Erases the element with key key from the tree.
void add_zeroes_and_shift(dimension_type n, dimension_type i)
Adds n zeroes before index i.
void erase_element_and_shift_left(dimension_type key)
Removes the element with key key (if it exists) and decrements by 1 all elements' keys that were grea...
iterator bisect_near(iterator hint, dimension_type key)
Searches an element with key key near hint.
dimension_type index() const
Returns the index of the element pointed to by *this.
dimension_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
static dimension_type max_size()
Returns the size() of the largest possible Sparse_Row.
void swap(Parma_Polyhedra_Library::Sparse_Row &x, Parma_Polyhedra_Library::Sparse_Row &y)
Swaps x with y.
void fast_shift(dimension_type i, iterator itr)
const_iterator cbegin() const
Returns an iterator that points at the first element.
Coefficient_traits::const_reference get(dimension_type i) const
Gets the i-th element in the sequence.
bool OK() const
Checks the invariant.