Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

List Class Template Reference

List template. More...

#include <list.h>

List of all members.

Public Methods

 List ()
 Default constructor.

 ~List ()
 Destructor. More...

void clear ()
 Clears the whole list.

T * first () const
 First item of the list. More...

T * next (T *item) const
 Gets next item in the list for iterating. More...

int isEmpty () const
 Check for empty list. More...

T * add (T *p)
 Addition to the list. More...

T * remove (T *p)
 Removing from the list. More...

void destroy (T *p)
 Destroying of an item. More...

int forEach (int(*f)(T *, void **), void **inout)
 Same action for each item of the list. More...

int length () const
 Length of list. More...


Private Attributes

ListItem_list
 the list.


Detailed Description

template<class T, class L>
class List< T, L >

List template.

This template class implements a list of objects inherited generally from ListItem class. Better use one of the direct descendants of ListItem class - LI1, LI2 etc. ListItem (or LI1, LI2 etc.) class gives to your class a possibility to be an item of a list of objects of the same type. Remember, one instance can be in the list only once (see implementation of ListItem class). In the list there will be the instance itself, not its copy. If you want to use the object in different lists, make it a descendant of more then one ListItem class (therefore use LI1, LI2 etc. - the same classes with different names) and specify the "list item" name 'L' (LI1, LI2) you're working with. For better explanation how it is working, see sources.

Note: in concrete list there can be objects of one type only.

Parameters:
T  type of objects in the list (T must be a descendant of ListItem class)
L  which ListItem direct descendant (LI1, LI2 etc.) is used in the list
See also:
ListItem, Hash
Author:
Marek Przeczek

Definition at line 64 of file list.h.


Constructor & Destructor Documentation

template<class T, class L>
List< T, L >::~List   [inline]
 

Destructor.

It destroys the list. The item of the list is destroyed only if its number of references after removing from the list is zero. Else it is only removed but not destroyed.

See also:
destroy()

Definition at line 84 of file list.h.


Member Function Documentation

template<class T, class L>
T* List< T, L >::add T *    p [inline]
 

Addition to the list.

This method adds a 'p' object to the list, increases number of references and returns pointer to just inserted object (equals to 'p').

Parameters:
p  pointer to object
Returns:
pointer to inserted object
See also:
remove()

Definition at line 134 of file list.h.

Referenced by Prof::event_arenaDelete(), Prof::event_arenaNew(), Prof::event_classLoad(), Prof::event_gcStart(), Prof::event_objectFree(), Prof::event_threadStart(), Hash::get(), and Prof::getAllocObject().

template<class T, class L>
void List< T, L >::destroy T *    p [inline]
 

Destroying of an item.

This method removes a 'p' object from the list just like remove() method does and destroys it in case its number of references reaches zero (it will be removed from memory).

Parameters:
p  pointer to object
See also:
remove()

Definition at line 174 of file list.h.

Referenced by clear().

template<class T, class L>
T* List< T, L >::first   const [inline]
 

First item of the list.

This method returns pointer to the first item of the list or NULL if the list is empty.

Returns:
pointer to the list item
See also:
next()

Definition at line 100 of file list.h.

Referenced by Thread::deactivate(), MonThreadMethod::deactivate(), Method::deactivate(), CpuThreadMethod::deactivate(), Class::deactivate(), AllocThreadObjectMethod::deactivate(), AllocThreadObject::deactivate(), AllocThreadMethod::deactivate(), AllocObjectMethod::deactivate(), AllocObject::deactivate(), Prof::event_arenaDelete(), Prof::event_gcFinish(), Prof::event_objectAlloc(), Prof::event_objectMove(), Hash::first(), forEach(), Hash::get(), Prof::getDataFromList(), length(), Hash::next(), and Hash::rehash().

template<class T, class L>
int List< T, L >::forEach int(*    f)(T *, void **),
void **    inout
[inline]
 

Same action for each item of the list.

This method does the action defined by f( T*, void**) function (or static method) for each item of the list. The 'inout' parameter will be used as the 2nd argument of the 'f' function, it is an additional parameter for optional in/out data. Its use depends on the user. If custom 'f' function returns nonzero value, this method quits immediatelly with the same return code as 'f'. Else when it finishes it returns 0.

Parameters:
f  pointer to function
inout  the second argument of 'f' function
Returns:
value

Definition at line 194 of file list.h.

Referenced by Prof::event_jvmShutDown(), Prof::event_threadStart(), and Hash::forEach().

template<class T, class L>
int List< T, L >::isEmpty   const [inline]
 

Check for empty list.

This method returns non-zero value if the list is empty or zero if it isn't.

Returns:
1 (empty list); 0 (non-empty list)

Definition at line 122 of file list.h.

template<class T, class L>
int List< T, L >::length   const [inline]
 

Length of list.

It returns the number of items in the list.

Returns:
number of items in the list

Definition at line 212 of file list.h.

template<class T, class L>
T* List< T, L >::next T *    item const [inline]
 

Gets next item in the list for iterating.

Returns NULL if the end of the list was reached.

Parameters:
item  pointer to list item
Returns:
pointer to the next list item or NULL
See also:
first()

Definition at line 111 of file list.h.

Referenced by Thread::deactivate(), MonThreadMethod::deactivate(), Method::deactivate(), CpuThreadMethod::deactivate(), Class::deactivate(), AllocThreadObjectMethod::deactivate(), AllocThreadObject::deactivate(), AllocThreadMethod::deactivate(), AllocObjectMethod::deactivate(), AllocObject::deactivate(), Prof::event_arenaDelete(), Prof::event_objectAlloc(), Prof::event_objectMove(), forEach(), Hash::get(), Prof::getDataFromList(), and length().

template<class T, class L>
T* List< T, L >::remove T *    p [inline]
 

Removing from the list.

This method removes a 'p' object from the list, decreases number of references and returns pointer to just removed object (equals to 'p').

Note: object is not removed from memory, only from the list.

Parameters:
p  pointer to object
Returns:
pointer to removed object
See also:
add()

Definition at line 155 of file list.h.

Referenced by destroy(), Prof::event_objectAlloc(), Hash::get(), and Hash::rehash().


The documentation for this class was generated from the following file:
Generated on Mon Jan 28 14:53:29 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001