Templated class, defined and implimented in file: hzTmplList.h

Single Linked list hzList is a single linked list with each element linked only to the next element. This saves space compared to a double linked list, but at the price of no reverse iteration. HadronZoo has not yet created a double linked variant as the experience so far has not suggested a pressing need for one. Thusfar, the usage pattern has been that lists are compiled, and then iterated from begining to end. At some point a double linked list wil be brought in. hzList provides an interator - the subclass Iter (hzList::Iter). The list iterator can be directly assigned to the begining of a list OR to another list iterator. Iteration is via the ++ operator until Iter::Valid() is no longer true. Objects are available via the iterator's Element() method. hzList does not itself provide methods of Insert() and Delete(), instead these are provided by the iterator. This is because there is no way to specify a position within a list except in terms of the 'current' element. The concept of a current element only exists within an iterator, not within a list. <b>Usage Considerations:</b> In common with other HadronZoo collection classes, hzList does not facilitate hard copies. Lists are intended to be short but potentially numerous. Many tree-like classes use lists as the means by which nodes manage sub-nodes. It is common for applications to have many thousands of lists and it is common for large numbers of these to be empty. So hzList only comprises a pointer to a 'data area' that is initialized to NULL in the constructor. Only when an object is added will the data area be created. The data area is deleted when the last object is deleted from the list. Note that it is common for items to be deleted during iteration as it becomes clear to the iterating process, the item is no longer needed. This is safe as long as only one iterator is operating on the list but not safe otherwise. Although the deletion takes place within a lock there is no way of knowing if another iterator is pointing to the item in question, and no way for the other iterator to know its current item is defunct. A process using the other iterator may attempt to perform an operation on a defunct object or seek to advance the other iterator on the basis of a defunct pointer.

This class employes the private sub-class _list_ca as follows:-

_list_ca

Constructors/Detructors

hzList*hzList(void)
hzList*hzList(hzList<OBJ>& op)
void~hzList(void)

Public Methods:

hzEcodeAdd(OBJ obj)Add an object to the end of the list
voidClear(void)Clear: Empty the list
uint32_tCount(void)Return the number of items in the list

Overloaded operators:

hzList<OBJ>&operator=(hzList<OBJ>& op)If the list is populated, clear it. Note will not delete objects if the list is of pointers rather than real objects and will therefore be a memory leak.

Member Variables:

hzList::_list_ca*mxPointer to internal list container