Regina Calculation Engine
|
Offers a hard-coded list of expensive objects that should only be created if they are required. More...
#include <utilities/nlistoncall.h>
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... | |
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.
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.
|
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.
|
inlinevirtual |
Destroys this list and all of the items it contains.
|
inline |
|
inline |
|
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.
|
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.
item | the new item to insert. |