BaseList Manual

About

maxon::BaseList is a class template for double linked lists. Elements of such a list should typically be access with iterators and not with indices.

Creation

A new list object can simply be created using the class template:

// This example creates and fills a new BaseList.
Definition: baselist.h:471
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:202
PyWideStringList * list
Definition: initconfig.h:447
#define iferr_return
Definition: resultbase.h:1524

The complete content of the BaseList can be deleted with:

Data

A maxon::BaseList stores maxon::BaseListNode elements. Such nodes contain the actual stored value and also references to the previous and next node.

New elements are added to the list with:

// This example creates a BaseList and adds elements to it.
// append elements
// insert object at the beginning
auto it = list.Begin();
list.Insert(it, 3) iferr_return;

If a given maxon::BaseList contains any elements can be checked with:

// This example checks if the given BaseList is empty.
// If not it is flushed.
if (!list.IsEmpty())
list.Flush();
if (!list.IsPopulated())
DiagnosticOutput("List is empty.");
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:170

A specific element stored in the maxon::BaseList can be accessed by its index:

// This example loops through all elements of the BaseList based on the element index.
const maxon::Int cnt = list.GetCount();
for (maxon::Int i = 0; i < cnt; ++i)
{
const maxon::Int value = list[i];
DiagnosticOutput("Value: @", value);
}
Py_ssize_t i
Definition: abstract.h:645
PyObject * value
Definition: abstract.h:715

Single elements of the maxon::BaseList can be removed with:

// This example deletes the first two elements of the given BaseList.
// deletes the first two elements
const auto begin = list.Begin();
list.Erase(begin, 2);
MAXON_ATTRIBUTE_FORCE_INLINE auto begin(COLLECTION &&c) -> decltype(c.Begin())
Definition: foreach.h:356

The overall maxon::BaseList can be resized with:

Iterate

Using iterators it is easily possible to iterate over all elements stored in the maxon::BaseList:

// This example switches the first and last element of the BaseList
// and loops through the list using the iterator.
// swap first and last element
const auto begin = list.Begin();
auto end = list.End();
end--;
list.Swap(begin, end);
// list all values
for (const maxon::Int it : list)
DiagnosticOutput("Value: @", it);
PyObject PyObject Py_ssize_t Py_ssize_t end
Definition: complexobject.h:63

Utility

Utility functions are:

Further Reading