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.

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.");

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);
}

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);

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);

Utility

Utility functions are:

Further Reading