oaCollection Class Template Reference

Inheritance diagram for oaCollection:

oaBaseCollection


Public Methods

 oaCollection (const oaCollection< obj, container > &coll)
oaBoolean includes (const obj *o)

Detailed Description

template<class obj, class container>
class oaCollection< obj, container >

Collections are template classes that represent sets of database objects. Collections are templatized for both the class of the starting object that the collection comes from, and the class of the objects contained in the collection. Collections are primarily used to initialize an oaIter so the members of the collection can be retrieved.

Collections are an effective way to work with one-to-many relationships. Collections allow the caller to traverse the contents of a collection, determine the collection size, and search the contents of the collection.

Note that constructing a collection is very quick, because the collection object simply signifies the collection. It does not gather the objects in the collection. Hence it is reasonable to construct a collection just to call isEmpty() on it.

All collections support common functions:

It is often faster to determine if a collection is empty than to determine the exact size of the collection. As a result, always use isEmpty() rather than getCount() == 0. getCount() is not constant time for all collections.

The most common way to use an oaCollection is to use it inline in the construction of an oaIter, never explicitly declaring the oaCollection. In the following example, view->getNets() returns an oaCollection.

        oaIter<oaNet>   nIter(view->getNets());
        while (oaNet   *net = nIter.getNext()) { ... }


Constructor & Destructor Documentation

template<class obj, class container>
oaCollection< obj, container >::oaCollection const oaCollection< obj, container > &    coll [inline]
 

This is the oaCollection copy constructor. It constructs a copy of the collection specified by coll.


Member Function Documentation

template<class obj, class container>
oaBoolean oaCollection< obj, container >::includes const obj *    object [inline]
 

This function determines if the given object is a member of this collection.

Note: This function is not guaranteed to be fast. For some collections, the database walks over all the members of the collection until this function either finds the object or tries all members of the collection.


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

Return to top of page