PPL  1.2
Parma_Polyhedra_Library::CO_Tree::const_iterator Class Reference

A const iterator on the tree elements, ordered by key. More...

#include <CO_Tree_defs.hh>

Public Types

typedef std::bidirectional_iterator_tag iterator_category
 
typedef const data_type value_type
 
typedef std::ptrdiff_t difference_type
 
typedef value_typepointer
 
typedef data_type_const_reference reference
 

Public Member Functions

 const_iterator ()
 Constructs an invalid const_iterator. More...
 
 const_iterator (const CO_Tree &tree)
 Constructs an iterator pointing to the first element of the tree. More...
 
 const_iterator (const CO_Tree &tree, dimension_type i)
 Constructs a const_iterator pointing to the i-th node of the tree. More...
 
 const_iterator (const const_iterator &itr)
 The copy constructor. More...
 
 const_iterator (const iterator &itr)
 Converts an iterator into a const_iterator. More...
 
void m_swap (const_iterator &itr)
 Swaps itr with *this. More...
 
const_iteratoroperator= (const const_iterator &itr)
 Assigns itr to *this . More...
 
const_iteratoroperator= (const iterator &itr)
 Assigns itr to *this . More...
 
const_iteratoroperator++ ()
 Navigates to the next element. More...
 
const_iteratoroperator-- ()
 Navigates to the previous element. More...
 
const_iterator operator++ (int)
 Navigates to the next element. More...
 
const_iterator operator-- (int)
 Navigates to the previous element. More...
 
data_type_const_reference operator* () const
 Returns the current element. More...
 
dimension_type index () const
 Returns the index of the element pointed to by *this. More...
 
bool operator== (const const_iterator &x) const
 Compares *this with x . More...
 
bool operator!= (const const_iterator &x) const
 Compares *this with x . More...
 

Private Member Functions

bool OK () const
 Checks the internal invariants, in debug mode only. More...
 

Private Attributes

const dimension_typecurrent_index
 A pointer to the corresponding element of the tree's indexes[] array. More...
 
const data_typecurrent_data
 A pointer to the corresponding element of the tree's data[] array. More...
 

Friends

dimension_type CO_Tree::dfs_index (const_iterator itr) const
 

Related Functions

(Note that these are not member functions.)

void swap (CO_Tree::const_iterator &x, CO_Tree::const_iterator &y)
 Swaps x with y. More...
 

Detailed Description

A const iterator on the tree elements, ordered by key.

Iterator increment and decrement operations are $O(1)$ time. These iterators are invalidated by operations that add or remove elements from the tree.

Definition at line 157 of file CO_Tree_defs.hh.

Member Typedef Documentation

Definition at line 161 of file CO_Tree_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::CO_Tree::const_iterator::const_iterator ( )
inlineexplicit

Constructs an invalid const_iterator.

This constructor takes $O(1)$ time.

Definition at line 359 of file CO_Tree_inlines.hh.

References OK().

360  : current_index(0), current_data(0) {
361 #if PPL_CO_TREE_EXTRA_DEBUG
362  tree = 0;
363 #endif
364  PPL_ASSERT(OK());
365 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
Parma_Polyhedra_Library::CO_Tree::const_iterator::const_iterator ( const CO_Tree tree)
inlineexplicit

Constructs an iterator pointing to the first element of the tree.

Parameters
treeThe tree that the new iterator will point to.

This constructor takes $O(1)$ time.

Definition at line 368 of file CO_Tree_inlines.hh.

References current_data, current_index, Parma_Polyhedra_Library::CO_Tree::empty(), OK(), and Parma_Polyhedra_Library::CO_Tree::unused_index.

369  : current_index(&(tree1.indexes[1])), current_data(&(tree1.data[1])) {
370 #if PPL_CO_TREE_EXTRA_DEBUG
371  tree = &tree1;
372 #endif
373  if (!tree1.empty()) {
374  while (*current_index == unused_index) {
375  ++current_index;
376  ++current_data;
377  }
378  }
379  PPL_ASSERT(OK());
380 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
static const dimension_type unused_index
An index used as a marker for unused nodes in the tree.
Parma_Polyhedra_Library::CO_Tree::const_iterator::const_iterator ( const CO_Tree tree,
dimension_type  i 
)
inline

Constructs a const_iterator pointing to the i-th node of the tree.

Parameters
treeThe tree that the new iterator will point to.
iThe index of the element in tree to which the iterator will point to.

The i-th node must be a node with a value or end().

This constructor takes $O(1)$ time.

Definition at line 383 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::empty(), Parma_Polyhedra_Library::CO_Tree::indexes, OK(), Parma_Polyhedra_Library::CO_Tree::reserved_size, and Parma_Polyhedra_Library::CO_Tree::unused_index.

385  : current_index(&(tree1.indexes[i])), current_data(&(tree1.data[i])) {
386 #if PPL_CO_TREE_EXTRA_DEBUG
387  tree = &tree1;
388 #endif
389  PPL_ASSERT(i != 0);
390  PPL_ASSERT(i <= tree1.reserved_size + 1);
391  PPL_ASSERT(tree1.empty() || tree1.indexes[i] != unused_index);
392  PPL_ASSERT(OK());
393 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
static const dimension_type unused_index
An index used as a marker for unused nodes in the tree.
Parma_Polyhedra_Library::CO_Tree::const_iterator::const_iterator ( const const_iterator itr)
inline

The copy constructor.

Parameters
itrThe iterator that will be copied.

This constructor takes $O(1)$ time.

Definition at line 396 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::OK().

396  {
397  (*this) = itr2;
398  PPL_ASSERT(OK());
399 }
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
Parma_Polyhedra_Library::CO_Tree::const_iterator::const_iterator ( const iterator itr)
inline

Converts an iterator into a const_iterator.

Parameters
itrThe iterator that will be converted into a const_iterator.

This constructor takes $O(1)$ time.

Definition at line 402 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::OK().

402  {
403  (*this) = itr2;
404  PPL_ASSERT(OK());
405 }
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317

Member Function Documentation

dimension_type Parma_Polyhedra_Library::CO_Tree::const_iterator::index ( ) const
inline

Returns the index of the element pointed to by *this.

Returns
the index of the element pointed to by *this.

Definition at line 498 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::OK().

Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::add_constraint(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::all_zeroes(), Parma_Polyhedra_Library::Sparse_Row::combine(), Parma_Polyhedra_Library::Sparse_Row::combine_needs_first(), Parma_Polyhedra_Library::MIP_Problem::erase_artificials(), Parma_Polyhedra_Library::Sparse_Row::find(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::first_nonzero(), Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::has_a_free_dimension_helper(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::have_a_common_variable(), Parma_Polyhedra_Library::Dense_Row::init(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::is_better_pivot(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::last_nonzero(), Parma_Polyhedra_Library::Sparse_Row::linear_combine(), Parma_Polyhedra_Library::Sparse_Row::lower_bound(), Parma_Polyhedra_Library::MIP_Problem::OK(), Parma_Polyhedra_Library::Sparse_Row::OK(), Parma_Polyhedra_Library::Dense_Row::operator=(), Parma_Polyhedra_Library::Sparse_Row::operator==(), Parma_Polyhedra_Library::operator==(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::MIP_Problem::steepest_edge_exact_entering_index(), Parma_Polyhedra_Library::MIP_Problem::steepest_edge_float_entering_index(), Parma_Polyhedra_Library::CO_Tree::structure_OK(), Parma_Polyhedra_Library::MIP_Problem::textbook_entering_index(), and Parma_Polyhedra_Library::PIP_Solution_Node::update_solution().

498  {
499  PPL_ASSERT(current_index != 0);
500  PPL_ASSERT(current_data != 0);
501  PPL_ASSERT(OK());
502 #if PPL_CO_TREE_EXTRA_DEBUG
503  PPL_ASSERT(current_index != &(tree->indexes[tree->reserved_size + 1]));
504 #endif
505  return *current_index;
506 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
void Parma_Polyhedra_Library::CO_Tree::const_iterator::m_swap ( const_iterator itr)
inline

Swaps itr with *this.

Parameters
itrThe iterator that will be swapped with *this.

This method takes $O(1)$ time.

Definition at line 408 of file CO_Tree_inlines.hh.

References current_data, current_index, OK(), Parma_Polyhedra_Library::CO_Tree::OK(), Parma_Polyhedra_Library::swap(), and Parma_Polyhedra_Library::CO_Tree::swap().

Referenced by Parma_Polyhedra_Library::swap().

408  {
409  using std::swap;
410  swap(current_data, itr.current_data);
411  swap(current_index, itr.current_index);
412 #if PPL_CO_TREE_EXTRA_DEBUG
413  swap(tree, itr.tree);
414 #endif
415  PPL_ASSERT(OK());
416  PPL_ASSERT(itr.OK());
417 }
void swap(CO_Tree::iterator &x, CO_Tree::iterator &y)
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
void swap(CO_Tree::const_iterator &x, CO_Tree::const_iterator &y)
Swaps x with y.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
bool Parma_Polyhedra_Library::CO_Tree::const_iterator::OK ( ) const
private

Checks the internal invariants, in debug mode only.

Definition at line 1317 of file CO_Tree.cc.

Referenced by const_iterator(), and m_swap().

1317  {
1318 #if PPL_CO_TREE_EXTRA_DEBUG
1319  if (tree == 0) {
1320  if (current_index != 0) {
1321  return false;
1322  }
1323  if (current_data != 0) {
1324  return false;
1325  }
1326  }
1327  else
1328  if (tree->reserved_size == 0) {
1329  if (current_index != 1 + static_cast<dimension_type*>(0)
1330  || current_data != 1 + static_cast<data_type*>(0)) {
1331  return false;
1332  }
1333  }
1334  else {
1335  if (current_index <= &(tree->indexes[0])) {
1336  return false;
1337  }
1338  if (current_index > &(tree->indexes[tree->reserved_size + 1])) {
1339  return false;
1340  }
1341  if (current_data <= &(tree->data[0])) {
1342  return false;
1343  }
1344  if (current_data > &(tree->data[tree->reserved_size + 1])) {
1345  return false;
1346  }
1347  if (*current_index == unused_index) {
1348  return false;
1349  }
1350  if (current_index - tree->indexes != current_data - tree->data) {
1351  return false;
1352  }
1353  }
1354 #endif
1355  return true;
1356 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
static const dimension_type unused_index
An index used as a marker for unused nodes in the tree.
bool Parma_Polyhedra_Library::CO_Tree::const_iterator::operator!= ( const const_iterator x) const
inline

Compares *this with x .

Parameters
xThe iterator that will be compared with *this.

Definition at line 517 of file CO_Tree_inlines.hh.

517  {
518  return !(*this == x);
519 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::CO_Tree::const_iterator::operator* ( ) const
inline

Returns the current element.

Definition at line 487 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::OK().

487  {
488  PPL_ASSERT(current_index != 0);
489  PPL_ASSERT(current_data != 0);
490  PPL_ASSERT(OK());
491 #if PPL_CO_TREE_EXTRA_DEBUG
492  PPL_ASSERT(current_index != &(tree->indexes[tree->reserved_size + 1]));
493 #endif
494  return *current_data;
495 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
CO_Tree::const_iterator & Parma_Polyhedra_Library::CO_Tree::const_iterator::operator++ ( )
inline

Navigates to the next element.

This method takes $O(1)$ time.

Definition at line 442 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::OK(), and Parma_Polyhedra_Library::CO_Tree::unused_index.

442  {
443  PPL_ASSERT(current_index != 0);
444  PPL_ASSERT(current_data != 0);
445 #if PPL_CO_TREE_EXTRA_DEBUG
446  PPL_ASSERT(current_index != &(tree->indexes[tree->reserved_size + 1]));
447 #endif
448  ++current_index;
449  ++current_data;
450  while (*current_index == unused_index) {
451  ++current_index;
452  ++current_data;
453  }
454  PPL_ASSERT(OK());
455  return *this;
456 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
static const dimension_type unused_index
An index used as a marker for unused nodes in the tree.
CO_Tree::const_iterator Parma_Polyhedra_Library::CO_Tree::const_iterator::operator++ ( int  )
inline

Navigates to the next element.

This method takes $O(1)$ time.

Definition at line 473 of file CO_Tree_inlines.hh.

473  {
474  const_iterator itr(*this);
475  ++(*this);
476  return itr;
477 }
const_iterator()
Constructs an invalid const_iterator.
CO_Tree::const_iterator & Parma_Polyhedra_Library::CO_Tree::const_iterator::operator-- ( )
inline

Navigates to the previous element.

This method takes $O(1)$ time.

Definition at line 459 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::OK(), and Parma_Polyhedra_Library::CO_Tree::unused_index.

459  {
460  PPL_ASSERT(current_index != 0);
461  PPL_ASSERT(current_data != 0);
462  --current_index;
463  --current_data;
464  while (*current_index == unused_index) {
465  --current_index;
466  --current_data;
467  }
468  PPL_ASSERT(OK());
469  return *this;
470 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
static const dimension_type unused_index
An index used as a marker for unused nodes in the tree.
CO_Tree::const_iterator Parma_Polyhedra_Library::CO_Tree::const_iterator::operator-- ( int  )
inline

Navigates to the previous element.

This method takes $O(1)$ time.

Definition at line 480 of file CO_Tree_inlines.hh.

480  {
481  const_iterator itr(*this);
482  --(*this);
483  return itr;
484 }
const_iterator()
Constructs an invalid const_iterator.
CO_Tree::const_iterator & Parma_Polyhedra_Library::CO_Tree::const_iterator::operator= ( const const_iterator itr)
inline

Assigns itr to *this .

Parameters
itrThe iterator that will be assigned into *this.

This method takes $O(1)$ time.

Definition at line 420 of file CO_Tree_inlines.hh.

References current_data, current_index, and Parma_Polyhedra_Library::CO_Tree::OK().

420  {
421  current_index = itr2.current_index;
422  current_data = itr2.current_data;
423 #if PPL_CO_TREE_EXTRA_DEBUG
424  tree = itr2.tree;
425 #endif
426  PPL_ASSERT(OK());
427  return *this;
428 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
CO_Tree::const_iterator & Parma_Polyhedra_Library::CO_Tree::const_iterator::operator= ( const iterator itr)
inline

Assigns itr to *this .

Parameters
itrThe iterator that will be assigned into *this.

This method takes $O(1)$ time.

Definition at line 431 of file CO_Tree_inlines.hh.

References Parma_Polyhedra_Library::CO_Tree::iterator::current_data, Parma_Polyhedra_Library::CO_Tree::iterator::current_index, and Parma_Polyhedra_Library::CO_Tree::OK().

431  {
432  current_index = itr2.current_index;
433  current_data = itr2.current_data;
434 #if PPL_CO_TREE_EXTRA_DEBUG
435  tree = itr2.tree;
436 #endif
437  PPL_ASSERT(OK());
438  return *this;
439 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317
bool Parma_Polyhedra_Library::CO_Tree::const_iterator::operator== ( const const_iterator x) const
inline

Compares *this with x .

Parameters
xThe iterator that will be compared with *this.

Definition at line 509 of file CO_Tree_inlines.hh.

References current_data, current_index, and Parma_Polyhedra_Library::CO_Tree::OK().

509  {
510  PPL_ASSERT((current_index == x.current_index)
511  == (current_data == x.current_data));
512  PPL_ASSERT(OK());
513  return (current_index == x.current_index);
514 }
const dimension_type * current_index
A pointer to the corresponding element of the tree's indexes[] array.
const data_type * current_data
A pointer to the corresponding element of the tree's data[] array.
bool OK() const
Checks the internal invariants, in debug mode only.
Definition: CO_Tree.cc:1317

Friends And Related Function Documentation

void swap ( CO_Tree::const_iterator x,
CO_Tree::const_iterator y 
)
related

Swaps x with y.

Definition at line 878 of file CO_Tree_inlines.hh.

878  {
879  x.m_swap(y);
880 }

Member Data Documentation

const data_type* Parma_Polyhedra_Library::CO_Tree::const_iterator::current_data
private

A pointer to the corresponding element of the tree's data[] array.

Definition at line 297 of file CO_Tree_defs.hh.

Referenced by const_iterator(), m_swap(), operator=(), and operator==().

const dimension_type* Parma_Polyhedra_Library::CO_Tree::const_iterator::current_index
private

A pointer to the corresponding element of the tree's indexes[] array.

Definition at line 294 of file CO_Tree_defs.hh.

Referenced by const_iterator(), Parma_Polyhedra_Library::CO_Tree::dfs_index(), m_swap(), operator=(), and operator==().


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