# Katabatic - Routing Toolbox

List of all members | Public Member Functions
GCellDensitySet Class Reference

GCell Set, sorted by density. More...

## Public Member Functions
| GCellDensitySet (unsigned int depth)
| GCellDensitySet (unsigned int depth, const std::vector< GCell *> &)
| ~GCellDensitySet ()
bool | empty () const
size_t | size () const
const std::set< GCell *, GCell::CompareByKey > & | getGCells () const
void | insert (GCell *)
void | erase (GCell *)
void | unqueue (GCell *)
void | requeue ()

## Detailed Description

GCell Set, sorted by density.

A small container helper to manage a set of GCell sorted by density on a specific layer `depth`.

The helper is implemented in term of a set. Once inserted in a set an element must not have is sorting key changed. But GCell density may change due to AutoSegment modifications during the lifetime of the set. To circumvent this problem, the GCell provide a key attribute to be used specifically with GCellDensitySet. This key act as a cached copy of the GCell density which is updated only by a call to GCell::updateKey() (and not GCell::updateDensity()). GCell which density have changed and key has to be updated must be signaled to set with the GCellDensityQueue::unqueue() method. When we want to update the sorting of the set on the new densities, we call GCellDensitySet::requeue() which, for each invalidated GCell do:

- Remove the GCell from the set.
- Update the key (call GCell::updateKey()).
- Reinsert the GCell in the set (thus with the updated key).

Typical usage:

GCellDensitySet gcells ( 2, *(getGCellGrid()->getGCellVector()) );
while ( true ) {
bool optimized = false;
std::set<GCell*,GCell::CompareByKey>::const_iterator igcell = gcells.getGCells().begin();
for ( ; igcell != gcells.getGCells().end() ; ++igcell ) {
if ( doSomeOptimization(*igcell) ) {
optimized = true;
gcells.unqueue( *igcell );
}
}
if (not optimized) break;
gcells.requeue();
}

## Constructor & Destructor Documentation

## ◆ GCellDensitySet() [1/2]

GCellDensitySet | ( | unsigned int | depth | ) |

Create a new empty GCellDensitySet, sorting on density of layer `depth`.

## ◆ GCellDensitySet() [2/2]

GCellDensitySet | ( | unsigned int | depth,
|  | const std::vector< GCell *> & | gcells
| ) |  |

Create a new empty GCellDensitySet, sorting on density of layer `depth`. Load the queue with the GCells supplied in the `gcells` vector.

References GCellDensitySet::requeue().

## ◆ ~GCellDensitySet()

~GCellDensitySet | ( |  | ) |

Delete a GCellDensitySet, if the queue is not empty, issue a warning.

## Member Function Documentation

## ◆ empty()

bool empty | ( |  | ) | const
| inline

Returns: true if the queue is empty.

## ◆ size()

size_t size | ( |  | ) | const
| inline

Returns: the numbers of elements in the queue.

## ◆ getGCells()

const std::set< GCell *, GCell::CompareByKey > & getGCells | ( |  | ) | const
| inline

Returns: the list of GCells currently in the queue.

## ◆ insert()

size_t insert | ( | GCell * | gcell | ) |
| inline

Insert `gcell` into the set.

## ◆ erase()

size_t erase | ( | GCell * | gcell | ) |
| inline

Remove `gcell` from the set.

## ◆ unqueue()

void unqueue | ( | GCell * | gcell | ) |
| inline

Invalidate `gcell`. The density of `gcell` may have changed and needs to be reinserted into the queue. It is temporarily set asides until the next call to GCellDensitySet::requeue().

## ◆ requeue()

void requeue | ( |  | ) |

Reinsert in the queue all the GCells that have been previously invalidated by a call to GCellDensitySet::unqueue(). This function calls GCell::updateKey() before reinserting the GCell.

Referenced by GCellDensitySet::GCellDensitySet().

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

- GCell.h
- GCell.cpp
- GCell.dox

Generated by doxygen 1.8.14 on Mon Apr 27 2020 | Return to top of page

Katabatic - Routing Toolbox | Copyright © 2008-2016 UPMC. All rights reserved