In file /home/blah/darwin2k/src/ddcore/misc/ptrList.h:

class ptrList

generic extensible list class.

Public Fields

[more]int n
number of elements currently in the list
[more]int max
maximum number of entries in the list
[more]void** list
array of items

Public Methods

[more] ptrList(int Max = 0)
constructor
[more] ptrList(const ptrList &other)
copy contructor
[more] ~ptrList(void)
destructor.
[more]ptrList& operator =(const ptrList &other)
assignment operator
[more]inline void* operator()(int i) const
returns the i'th list entry.
[more]inline void*& operator()(int i)
returns a reference to the i'th list entry.
[more]inline void* el(int i) const
returns the i'th list entry.
[more]inline void*& el(int i)
returns a reference to the i'th list entry.
[more]inline void clear(void)
clears the list by setting the number of elements to zero.
[more]int addPtr(void* p)
adds a pointer to the end of the list, resizing if necessary
[more]inline int addInt(int i)
adds an int to the end of the list, resizing if necessary
[more]int isPresent(const void* p) const
returns 1 if the indicated pointer is present in the list
[more]inline int isPresent(int i) const
returns 1 if the indicated int is in the list
[more]inline int getIndex(int i) const
returns the index of the first occurrence of 'i' in the list, or -1 if not found
[more]int getIndex(const void* p) const
returns the index of the first occurrence of 'p' in the list, or -1 if not found
[more]inline int getInt(int i) const
typecasts the i'th list item to an int and returns it.
[more]inline void* last(void)
returns the last element in the list.
[more]int removePtr(const void* p)
If p is present in the list, the last entry in the list is moved into the first spot in the list where p occurs.
[more]int removePtr(int index)
Removes the specified entry from the list.
[more]void merge(const ptrList* other)
adds any entries in 'other' to this list if they were not already present.
[more]void sort(int (*cmp)(const void* p1, const void* p2))
sorts the entire list using qsort with the given comparison function
[more]void sort(int startIdx, int n, int (*cmp)(const void* p1, const void* p2))
sorts 'n' list entries beginning at 'startIdx' using qsort with the given comparison function
[more]int removeNullPointers(void)
removes any NULL entries from the list.


Documentation

generic extensible list class. This list is resized automatically by the addPtr() method, but *not* by accessing elements beyond the current end of the list. Users are responsible for freeing any dynamically allocated items that they add to the list.
oint n
number of elements currently in the list

oint max
maximum number of entries in the list

ovoid** list
array of items

o ptrList(int Max = 0)
constructor

o ptrList(const ptrList &other)
copy contructor

o ~ptrList(void)
destructor. Does not call delete for items in the list

optrList& operator =(const ptrList &other)
assignment operator

oinline void* operator()(int i) const
returns the i'th list entry. WARNING: does not check to make sure that 'i' is in range

oinline void*& operator()(int i)
returns a reference to the i'th list entry. WARNING: does not check to make sure that 'i' is in range.

oinline void* el(int i) const
returns the i'th list entry. WARNING: does not check to make sure that 'i' is in range

oinline void*& el(int i)
returns a reference to the i'th list entry. WARNING: does not check to make sure that 'i' is in range.

oinline void clear(void)
clears the list by setting the number of elements to zero. Does not deallocate the actual array, though.

oint addPtr(void* p)
adds a pointer to the end of the list, resizing if necessary

oinline int addInt(int i)
adds an int to the end of the list, resizing if necessary

oint isPresent(const void* p) const
returns 1 if the indicated pointer is present in the list

oinline int isPresent(int i) const
returns 1 if the indicated int is in the list

oinline int getIndex(int i) const
returns the index of the first occurrence of 'i' in the list, or -1 if not found

oint getIndex(const void* p) const
returns the index of the first occurrence of 'p' in the list, or -1 if not found

oinline int getInt(int i) const
typecasts the i'th list item to an int and returns it. WARNING: does not check to make sure 'i' is in range.

oinline void* last(void)
returns the last element in the list. WARNING: this doesn't check to make sure the list isn't empty.

oint removePtr(const void* p)
If p is present in the list, the last entry in the list is moved into the first spot in the list where p occurs. Returns the index of p, or -1 if p was not found in the list.

oint removePtr(int index)
Removes the specified entry from the list. Returns the index, or -1 if the index was out of range.

ovoid merge(const ptrList* other)
adds any entries in 'other' to this list if they were not already present. This uses the simplest possible algorith, so it can be slow for very large lists.

ovoid sort(int (*cmp)(const void* p1, const void* p2))
sorts the entire list using qsort with the given comparison function

ovoid sort(int startIdx, int n, int (*cmp)(const void* p1, const void* p2))
sorts 'n' list entries beginning at 'startIdx' using qsort with the given comparison function

oint removeNullPointers(void)
removes any NULL entries from the list. Items from the end of the list are moved to the locations of existing NULL pointers.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.