Regina Calculation Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
regina::NListOnCall< T > Class Template Referenceabstract

Offers a hard-coded list of expensive objects that should only be created if they are required. More...

#include <utilities/nlistoncall.h>

Inheritance diagram for regina::NListOnCall< T >:
regina::boost::noncopyable

Public Types

typedef std::list< const T * >
::const_iterator 
iterator
 An iterator over this list. More...
 

Public Member Functions

 NListOnCall ()
 Creates a new list structure. More...
 
virtual ~NListOnCall ()
 Destroys this list and all of the items it contains. More...
 
iterator begin () const
 Returns an iterator pointing to the first item in this list. More...
 
iterator end () const
 Returns an iterator pointing past the end of this list (i.e., just after the last item). More...
 

Protected Member Functions

void insert (T *item)
 Adds the given item to the end of this list. More...
 
virtual void initialise ()=0
 Fills this list with items. More...
 

Detailed Description

template<typename T>
class regina::NListOnCall< T >

Offers a hard-coded list of expensive objects that should only be created if they are required.

An example might include a large hard-coded list of triangulations (which are expensive to construct) that will only be required in special scenarios, and not in everyday use of the software.

A particular hard-coded list should be defined by a subclass of NListOnCall. The list should be filled within the pure virtual routine initialise(), which must be overridden.

A static list of this type is relatively cheap to create. The list will not actually be filled (and the expensive objects will not be created) until the first time the list is traversed. Specifically, the list will be filled on the first call to begin().

Only an extremely simple form of list traversal is offered: Routines begin() and end() are defined, which return forward iterators that can be used to run through the list contents.

Lists of this type are designed to be constant. Aside from the initial list population in the initialise() routine and the final list destruction (in which all of the stored objects will also be destroyed), the list and its objects should never be changed. Because of this, the iterator type returns only constant pointers to list objects.

Note that T is the expensive object type, not a pointer type to such an object.

Python:
Not present.

Member Typedef Documentation

template<typename T>
typedef std::list<const T*>::const_iterator regina::NListOnCall< T >::iterator

An iterator over this list.

This operates as a forward iterator in a manner consistent with the standard C++ library. It does not allow either the list or its individual objects to be changed.

Constructor & Destructor Documentation

template<typename T>
regina::NListOnCall< T >::NListOnCall ( )
inline

Creates a new list structure.

The list will not be filled with items; this does not happen until the first time that begin() is called.

template<typename T>
virtual regina::NListOnCall< T >::~NListOnCall ( )
inlinevirtual

Destroys this list and all of the items it contains.

Member Function Documentation

template<typename T>
iterator regina::NListOnCall< T >::begin ( ) const
inline

Returns an iterator pointing to the first item in this list.

If the list has not yet been filled with items, this will take place now. Thus the first call to begin() will be expensive, but subsequent calls will be extremely cheap.

Returns
an iterator pointing to the first item.
template<typename T>
iterator regina::NListOnCall< T >::end ( ) const
inline

Returns an iterator pointing past the end of this list (i.e., just after the last item).

Precondition
The begin() routine has been called at least once (otherwise the list will not yet have been filled).
Returns
a past-the-end iterator.
template<typename T>
virtual void regina::NListOnCall< T >::initialise ( )
protectedpure virtual

Fills this list with items.

The particular set of items to use will typically depend on the particular subclass of NListOnCall that is being defined.

This routine will be run the first time that begin() is called on each list, and will not be run again.

Implemented in regina::NSatBlockStarterSet.

template<typename T>
void regina::NListOnCall< T >::insert ( T *  item)
inlineprotected

Adds the given item to the end of this list.

This routine should only ever be called from within a subclass implementation of initialise().

The given item will be owned by this list, and will be destroyed when this list is destroyed.

Parameters
itemthe new item to insert.

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

Copyright © 1999-2014, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).