List Class Template Reference

Template class for the Dakota bookkeeping list. More...

List of all members.

Public Member Functions

 List ()
 Default constructor.
 List (const List< T > &a)
 Copy constructor.
 ~List ()
 Destructor.
template<class InputIter>
 List (InputIter first, InputIter last)
 Range constructor (member template).
List< T > & operator= (const List< T > &a)
 assignment operator
void write (ostream &s) const
 Writes a List to an output stream.
void read (MPIUnpackBuffer &s)
 Reads a List from an MPIUnpackBuffer after an MPI receive.
void write (MPIPackBuffer &s) const
 Writes a List to a MPIPackBuffer prior to an MPI send.
size_t entries () const
 Returns the number of items that are currently in the list.
get ()
 Removes and returns the first item in the list.
removeAt (size_t index)
 Removes and returns the item at the specified index.
bool remove (const T &a)
 Removes the specified item from the list.
void insert (const T &a)
 Adds the item a to the end of the list.
bool contains (const T &a) const
 Returns TRUE if list contains object a, returns FALSE otherwise.
bool find (bool(*test_fn)(const T &, const void *), const void *test_fn_data, T &found_item) const
 finds and sets k to this object
List< T >::iterator find (bool(*test_fn)(const T &, const void *), const void *test_fn_data)
 Returns an iterator pointing to an object that the test function finds.
size_t index (bool(*test_fn)(const T &, const void *), const void *test_fn_data) const
 Returns the index of object that the test function finds.
size_t index (const T &a) const
 Returns the index of the object.
size_t count (bool(*test_fn)(const T &, const void *), const void *test_fn_data) const
 Returns the number of items in the list that satisfy the test function.
size_t count (const T &a) const
 Returns the number of items in the list equal to object a.
T & operator[] (size_t i)
 Returns the object at index i (can use as lvalue).
const T & operator[] (size_t i) const
 Returns the object at index i, const (can't use as lvalue).


Detailed Description

template<class T>
class Dakota::List< T >

Template class for the Dakota bookkeeping list.

The List is the common list class for Dakota. It inherits from either the RW list class or the STL list class. Extends the base list class to add Dakota specific methods Builds upon the previously existing DakotaValList class


Member Function Documentation

T get (  ) 

Removes and returns the first item in the list.

Remove and return item from front of list. Returns the object pointed to by the list::begin() iterator. It also deletes the first node by calling the list::pop_front() method. Note: get() is not the same as list::front() since the latter would return the 1st item but would not delete it.

T removeAt ( size_t  index  ) 

Removes and returns the item at the specified index.

Removes the item at the index specified. Uses the STL advance() function to step to the appropriate position in the list and then calls the list::erase() method.

bool remove ( const T &  a  ) 

Removes the specified item from the list.

Removes the first instance matching object a from the list (and therefore differs from the STL list::remove() which removes all instances). Uses the STL find() algorithm to find the object and the list::erase() method to perform the remove.

void insert ( const T &  a  )  [inline]

Adds the item a to the end of the list.

Insert item at end of list, calls list::push_back() method.

bool contains ( const T &  a  )  const [inline]

Returns TRUE if list contains object a, returns FALSE otherwise.

Uses the STL find() algorithm to locate the first instance of object a. Returns true if an instance is found.

bool find ( bool(*)(const T &, const void *)  test_fn,
const void *  test_fn_data,
T &  found_item 
) const

finds and sets k to this object

Find the first item in the list which satisfies the test function. Sets k if the object is found.

List< T >::iterator find ( bool(*)(const T &, const void *)  test_fn,
const void *  test_fn_data 
)

Returns an iterator pointing to an object that the test function finds.

Find the first item in the list which satisfies the test function and return an iterator pointing to it.

size_t index ( bool(*)(const T &, const void *)  test_fn,
const void *  test_fn_data 
) const

Returns the index of object that the test function finds.

Returns the index of the first item in the list which satisfies the test function. Uses a single list traversal to both locate the object and return its index (generic algorithms would require two loop traversals).

size_t index ( const T &  a  )  const

Returns the index of the object.

Returns the index of the first item in the list which matches the object a. Uses a single list traversal to both locate the object and return its index (generic algorithms would require two loop traversals).

size_t count ( const T &  a  )  const [inline]

Returns the number of items in the list equal to object a.

Uses the STL count() algorithm to return the number of occurences of the specified object.

T & operator[] ( size_t  i  ) 

Returns the object at index i (can use as lvalue).

Returns item at position i of the list by stepping through the list using forward or reverse STL iterators (depending on which end of the list is closer to the desired item). Once the object is found, it returns the value pointed to by the iterator.

This functionality is inefficient in 0->len loop-based list traversals and is being replaced by iterator-based list traversals in the main DAKOTA code. For isolated look-ups of a particular index, however, this approach is acceptable.

const T & operator[] ( size_t  i  )  const

Returns the object at index i, const (can't use as lvalue).

Returns const item at position i of the list by stepping through the list using forward or reverse STL iterators (depending on which end of the list is closer to the desired item). Once the object is found it returns the value pointed to by the iterator.

This functionality is inefficient in 0->len loop-based list traversals and is being replaced by iterator-based list traversals in the main DAKOTA code. For isolated look-ups of a particular index, however, this approach is acceptable.


The documentation for this class was generated from the following file:
Generated on Wed Nov 5 19:54:06 2008 for DAKOTA by  doxygen 1.5.1