#include <list.h>
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. |
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.
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 |
Definition at line 64 of file list.h.
|
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.
|
|
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').
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().
|
|
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).
Definition at line 174 of file list.h. Referenced by clear().
|
|
First item of the list. This method returns pointer to the first item of the list or NULL if the list is empty.
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().
|
|
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.
Definition at line 194 of file list.h. Referenced by Prof::event_jvmShutDown(), Prof::event_threadStart(), and Hash::forEach().
|
|
Check for empty list. This method returns non-zero value if the list is empty or zero if it isn't.
|
|
Length of list. It returns the number of items in the list.
|
|
Gets next item in the list for iterating. Returns NULL if the end of the list was reached.
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().
|
|
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.
Definition at line 155 of file list.h. Referenced by destroy(), Prof::event_objectAlloc(), Hash::get(), and Hash::rehash().
|