SbPList Class Reference
Base Classes

The SbPList class is a container class for void pointers. More...

`#include <Inventor/lists/SbPList.h>`

Inheritance diagram for SbPList:

## Public Member Functions

| SbPList (const int sizehint=DEFAULTSIZE)
| SbPList (const SbPList &l)
| ~SbPList ()
void | copy (const SbPList &l)
SbPList & | operator= (const SbPList &l)
void | fit (void)
void | append (void *item)
int | find (const void *item) const
void | insert (void *item, const int insertbefore)
void | removeItem (void *item)
void | remove (const int index)
void | removeFast (const int index)
int | getLength (void) const
void | truncate (const int length, const int fit=0)
void ** | getArrayPtr (const int start=0) const
void *& | operator[] (const int index) const
int | operator== (const SbPList &l) const
int | operator!= (const SbPList &l) const
void * | get (const int index) const
void | set (const int index, void *item)

## Protected Member Functions

void | expand (const int size)
int | getArraySize (void) const

## Detailed Description

The SbPList class is a container class for void pointers.

## Constructor & Destructor Documentation

## SbPList() [1/2]

SbPList::SbPList | ( | const int | sizehint = DEFAULTSIZE | ) |

This constructor initializes the internal allocated size for the list to sizehint. Note that the list will still initially contain zero items.

Default constructor.

## SbPList() [2/2]

SbPList::SbPList | ( | const SbPList & | l | ) |

Copy constructor.

## ~SbPList()

SbPList::~SbPList | ( |  | ) |

Destructor.

## Member Function Documentation

## copy()

void SbPList::copy | ( | const SbPList & | l | ) |

Make this list a copy of l.

## operator=()

SbPList & SbPList::operator= | ( | const SbPList & | l | ) |

Assignment operator

## fit()

void SbPList::fit | ( | void |  | ) |

Fit the allocated array exactly around the length of the list, discarding memory spent on unused pre-allocated array cells.

You should normally not need or want to call this method, and it is only available for the sake of having the option to optimize memory usage for the unlikely event that you should throw around huge SbList objects within your application.

## append()

void SbPList::append | ( | void * | item | ) |

inline

Append item to the end of the list.

Automatically allocates more items internally if needed.

## find()

int SbPList::find | ( | const void * | item | ) | const

Return index of first occurrence of item in the list, or -1 if item is not present.

## insert()

void SbPList::insert | ( | void * | item,
|  | const int | insertbefore )

Insert item at index insertbefore.

insertbefore should not be larger than the current number of items in the list.

## removeItem()

void SbPList::removeItem | ( | void * | item | ) |

Removes an item from the list. If there are several items with the same value, removes the item with the lowest index.

## remove()

void SbPList::remove | ( | const int | index | ) |

Remove the item at index, moving all subsequent items downwards one place in the list.

## removeFast()

void SbPList::removeFast | ( | const int | index | ) |

inline

Remove the item at index, moving the last item into its place and truncating the list.

## getLength()

int SbPList::getLength | ( | void |  | ) | const

inline

Returns number of items in the list.

## truncate()

void SbPList::truncate | ( | const int | length,
|  | const int | fit = 0 )

inline

Shorten the list to contain length elements, removing items from index length and onwards.

If fit is non-zero, will also shrink the internal size of the allocated array. Note that this is much less efficient than not re-fitting the array size.

## getArrayPtr()

void ** SbPList::getArrayPtr | ( | const int | start = 0 | ) | const

inline

Returns pointer to a non-modifiable array of the lists elements. start specifies an index into the array.

The caller is not responsible for freeing up the array, as it is just a pointer into the internal array used by the list.

## operator[]()

void *& SbPList::operator[] | ( | const int | index | ) | const

inline

Returns element at index.

Will automatically expand the size of the internal array if index is outside the current bounds of the list. The values of any additional pointers are then set to `NULL`.

## operator==()

int SbPList::operator== | ( | const SbPList & | l | ) | const

Equality operator. Returns `TRUE` if this list and l are identical, containing the exact same ordered set of elements.

## operator!=()

int SbPList::operator!= | ( | const SbPList & | l | ) | const

inline

Inequality operator. Returns `TRUE` if this list and l are not equal.

## get()

void * SbPList::get | ( | const int | index | ) | const

inline

Returns element at index. Does not expand array bounds if index is outside the list.

## set()

void SbPList::set | ( | const int | index,
|  | void * | item )

inline

Index operator to set element at index. Does not expand array bounds if index is outside the list.

## expand()

void SbPList::expand | ( | const int | size | ) |

inline protected

Expand the list to contain size items. The new items added at the end have undefined value.

## getArraySize()

int SbPList::getArraySize | ( | void |  | ) | const

inline protected

Return number of items there's allocated space for in the array.

See also
  getLength()

The documentation for this class was generated from the following files:

- lists/SbPList.h
- SbPList.cpp