Collection description (API) More...
Public Member Functions | |
virtual | ~Collection () |
virtual Collection< Type > * | getClone () const =0 |
virtual Locator< Type > * | getLocator () const =0 |
virtual unsigned | getSize () const |
Type | getFirst () const |
GenericCollection< Type > | getSubSet (const Filter< Type > &filter) const |
template<class SubType > | |
GenericCollection< SubType > | getSubSet () const |
template<class SubType > | |
GenericCollection< SubType > | getSubSet (const Filter< SubType > &filter) const |
Collection description (API)
Collections introduce the concept of set of elements.
Strictly speaking collections are not containers (in the STL way) but indeed set descriptors. For example, the set of instances called by a cell, which are located within a given rectangular area, will be a subtype of Collection<Instance*> whose first attribute will be a pointer to the cell and a second attribute the rectangular area.
Main characteristics of Collections:
The Collections now provides a basic iterator support to allow the C++11 for
contruct:
Although the forEach
macro is still retained for backward compatibility, it is advisable to use the C++11 way.
Collections are to be used in conjunction with the forEach
macro which allows to easily iterate over the elements. Iteration is done through a simplistic iterator which have overload for the operator*()
and operator->()
The forEach
macro takes three arguments:
forEach(type,iterator,collection) | |
---|---|
type | Element's type of the collection. |
iterator | Name of the iterator's variable. |
collection | An appropriate collection to iterate over, that is, built over type elements. |
To use the forEach macro outside the Hurricane namespace, the following statement is necessary:
Here is a small example of a loop:
The collections provide the generic getCollection()
function which allows to convert its argument into a generic collection. It has no specific interest for Hurricane collections, but this function is overloaded for STL containers.
This allows to handle a STL containers like a normal collection as shown in the following example:
The same will occur anyway if you do:
Each type of collection provides an associated Locator for tracing through the corresponding set of elements.
Each locator moves efficiently through the data structure without building (in the form of a list or any other container type) the set of elements defined by the collection (it may however use a stack (or something else) to manage recursive traces).
The elements are therefore visited in the order with which they are internally stored. No assumptions must be made about this ordering. However, collections representing an STL container are visited in the same order than the container's one.
If you need to visit the objects in a given order, you must first fill a STL container: either a vector to be sorted accordingly or a set with the given sort criteria (see the Fill method below).
|
inlinevirtual |
Destroys the collection but doesn't acts on elements refered by this collection.
|
pure virtual |
Allocates and returns a clone (copy) of the collection (whatever be its type).
|
pure virtual |
Allocates and returns a locator adapted to visit the elements of the collection.
Referenced by Hurricane::Collection< Type >::getFirst(), and Hurricane::Collection< Type >::getSize().
|
inlinevirtual |
Returns: the number of objects identified within the collection.
References Hurricane::Collection< Type >::getLocator().
|
inline |
Returns: the first element of the collection.
References Hurricane::Collection< Type >::getLocator().
|
inline |
Returns: the collection representing the subset of elements accepted by the filter.
|
inline |
Returns: the collection corresponding to the subset of elements of type <SubType>
.
|
inline |
Returns: the collection representing the subset of elements of type <SubType>
accepted by the filter.
And somewher later:
Generated by doxygen 1.9.1 on Thu Aug 11 2022 | Return to top of page |
Hurricane VLSI Database | Copyright © 2000-2020 Bull S.A. All rights reserved |