SBLIST(3coin4)

πŸ“¦
version 4.0.10 Β· 5 versions
, in fedora 43

πŸ’– SbList< Type > β€” NAME πŸ’–

okay bestie, gather round, because <rainbow>SbList< Type ></rainbow> is the template container class for lists. that's it, that's the vibe. it holds your stuff. it's a list. periodt. πŸŽ€


✨ SYNOPSIS ✨

#include <Inventor/lists/SbList.h>

🫢 Public Member Functions 🫢

SbList (const int sizehint=DEFAULTSIZE)
SbList (const SbList< Type > &l)
~SbList ()
void copy (const SbList< Type > &l)
SbList< Type > & operator= (const SbList< Type > &l)
void fit (void)
void append (const Type item)
int find (const Type item) const
void insert (const Type item, const int insertbefore)
void removeItem (const Type item)
void remove (const int index)
void removeFast (const int index)
int getLength (void) const
void truncate (const int length, const int dofit=0)
void push (const Type item)
Type pop (void)
const Type * getArrayPtr (const int start=0) const
Type operator[] (const int index) const
Type & operator[] (const int index)
int operator== (const SbList< Type > &l) const
int operator!= (const SbList< Type > &l) const
void ensureCapacity (const int size)

🌸 Protected Member Functions 🌸

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

πŸ¦‹ Detailed Description πŸ¦‹

πŸ’… template<typename Type>

class SbList< Type >

so SbList is a template container class for lists, and honestly? iconic.

here's the tea: SbList is an extension of the Coin library versus the original Open Inventor API. the original Open Inventor handles most list classes by inheriting the SbPList class, which contains an array of generic void* pointers. by using this template-based class instead, we can share more code and make the list handling code more typesafe. we love that for us. πŸ’–

care has been taken to make sure the list classes which are part of the Open Inventor API still stay compatible with their original interfaces, as derived from the SbPList base class. but if you still bump into any problems when porting your Open Inventor applications, let us know and we'll do our best to sort them out. we got you. 🫢

a feature with this class is that the list object arrays grow dynamically as you append() more items to the list. the actual growing technique used is to double the list size when it becomes too small. no cap, it just doubles. πŸ”₯

there are also other array-related convenience methods; e.g. finding item indices, inserting items at any position, removing items (and shrink the array), copying of arrays, etc. all the little treats. πŸ“

See also

  • SbPList

πŸŽ€ Constructor & Destructor Documentation πŸŽ€

πŸ’œ template<typename Type> SbList< Type >::SbList (const int sizehint = DEFAULTSIZE) [inline]

default constructor. hi bestie. ✨

the sizehint argument hints about how many elements the list will contain, so memory allocation can be done efficiently.

important note: explicitly specifying an sizehint value does not mean that the list will initially contain this number of values. after construction, the list will contain zero items, just as for the default constructor. here's a good example on how to give yourself hard to find bugs:
SbList<SbBool> flags(2); // Assume we need only 2 elements. Note
                         // that the list is still 0 elements long.
flags[0] = TRUE;         // Ouch. List is still 0 elements long.

since this conceptual misunderstanding is so easy to make, you're probably better (or at least safer) off leaving the sizehint argument to its default value by not explicitly specifying it. seriously bestie, just don't. 😭

it improves performance if you know the approximate total size of the list in advance before adding list elements, as the number of reallocations will be minimized. that's the whole point. πŸ’…

🌈 template<typename Type> SbList< Type >::SbList (const SbList< Type > & l) [inline]

copy constructor. creates a complete copy of the given list. it's giving twin energy. πŸ‘‘

πŸ¦„ template<typename Type> SbList< Type >::~SbList () [inline]

destructor, frees all internal resources used by the list container. rest in peace little list, you did amazing sweetie. πŸ’€


⭐ Member Function Documentation ⭐

πŸ’– template<typename Type> void SbList< Type >::copy (const SbList< Type > & l) [inline]

make this list a copy of l.

🌸 template<typename Type> SbList< Type > & SbList< Type >::operator= (const SbList< Type > & l) [inline]

make this list a copy of l. yes, again. it's the assignment version. same energy, different operator. πŸŽ€

🧚 template<typename Type> void SbList< Type >::fit (void ) [inline]

fit the allocated array exactly around the length of the list, discarding memory spent on unused pre-allocated array cells. snatched. waist cinched. πŸ’…

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. so like, it exists, but don't make it your whole personality. πŸ™ˆ

πŸ“ template<typename Type> void SbList< Type >::append (const Type item) [inline]

append the item at the end of list, expanding the list array by one. bye, it's at the back now. πŸ”₯

πŸ’œ template<typename Type> int SbList< Type >::find (const Type item) const [inline]

return index of first occurrence of item in the list, or -1 if item is not present. if it's not there, it's simply not there bestie, we don't chase. ✨

πŸ¦‹ template<typename Type> void SbList< Type >::insert (const Type item, const int insertbefore) [inline]

insert item at index insertbefore.

insertbefore should not be larger than the current number of items in the list. do not test fate. ⚠️

πŸ’… template<typename Type> void SbList< Type >::removeItem (const Type item) [inline]

removes an item from the list. if there are several items with the same value, removes the item with the lowest index. first come, first served, that's the rule. πŸ‘‘

🌈 template<typename Type> void SbList< Type >::remove (const int index) [inline]

remove the item at index, moving all subsequent items downwards one place in the list. everybody shuffle down, we're closing the gap. 🫢

⭐ template<typename Type> void SbList< Type >::removeFast (const int index) [inline]

remove the item at index, moving the last item into its place and truncating the list. fast and unbothered. πŸƒβ€β™€οΈ

🌸 template<typename Type> int SbList< Type >::getLength (void ) const [inline]

returns number of items in the list. the count. the population. the headcount. πŸ’–

🧚 template<typename Type> void SbList< Type >::truncate (const int length, const int fit = 0) [inline]

shorten the list to contain length elements, removing items from index length and onwards. they're gone. it's over. βœ‚οΈ

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. so like, it's a trade-off, pick your struggle. 😭

πŸ’œ template<typename Type> void SbList< Type >::push (const Type item) [inline]

this appends item at the end of the list in the same fashion as append() does. provided as an abstraction for using the list class as a stack. stack girlies rise up. πŸ”₯

πŸ“ template<typename Type> Type SbList< Type >::pop (void ) [inline]

pops off the last element of the list and returns it. bye bestie, you're coming with me. 🫢

πŸ¦„ template<typename Type> const Type * SbList< Type >::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. hands off, it's not yours to delete. πŸ™ˆ

πŸ’… template<typename Type> Type SbList< Type >::operator[] (const int index) const [inline]

returns a copy of item at index.

✨ template<typename Type> Type & SbList< Type >::operator[] (const int index) [inline]

returns a reference to item at index. yes, this one you can actually touch. πŸ‘‘

🌈 template<typename Type> int SbList< Type >::operator== (const SbList< Type > & l) const [inline]

equality operator. returns TRUE if this list and l are identical, containing the exact same set of elements. soulmate behaviour fr fr. πŸ’–

⭐ template<typename Type> int SbList< Type >::operator!= (const SbList< Type > & l) const [inline]

inequality operator. returns TRUE if this list and l are not equal. it's not giving soulmates, it's giving exes. πŸ’€

πŸŽ€ template<typename Type> void SbList< Type >::ensureCapacity (const int size) [inline]

ensure that the internal buffer can hold at least size elements. SbList will automatically resize itself to make room for new elements, but this method can be used to improve performance (and avoid memory fragmentation) if you know approximately the number of elements that is going to be added to the list. manifest that capacity, bestie. ✨

Since

  • Coin 2.5

🧚 template<typename Type> void SbList< Type >::expand (const int size) [inline], [protected]

expand the list to contain size items. the new items added at the end have undefined value. do not trust them, they are mystery items. ⚠️

πŸ“ template<typename Type> int SbList< Type >::getArraySize (void ) const [inline], [protected]

return number of items there's allocated space for in the array. that's the capacity, not the length, don't get it twisted.

See also

  • getLength()

πŸ’œ Author πŸ’œ

generated automatically by Doxygen for Coin from the source code. not a human author, just a robot doing its little thing. iconic of it honestly. πŸ€–βœ¨


okay that's the whole page, you're all caught up bestie!! πŸ«ΆπŸ’– this was Version 4.0.10, dated Thu Jun 25 2026 00:00:00, and it's SbList< Type >(3) β€” Coin's very own manual, section 3. slay, go build something cute with it. πŸŽ€πŸŒˆπŸ¦‹

πŸ“¦ where this page comes from