BaseList Manual

内容表

关于

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.
maxon::BaseList<maxon::Int> list;
列表。 Append (1) iferr_return ; 列表。 Append (2) iferr_return ;

The complete content of the BaseList can be deleted with:

数据

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. maxon::BaseList<maxon::Int> list;

// append elements 列表。 Append (1) iferr_return ; 列表。 Append (2) iferr_return ;

// insert object at the beginning auto it = list. Begin (); 列表。 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 ()) 列表。 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 (); 列表。 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 --; 列表。 Swap ( begin , end );

// list all values for ( const maxon::Int it : list) DiagnosticOutput ( "Value: @" , it);

Utility

Utility functions are:

延伸阅读

maxon::BaseList::Append
ResultRef< T > Append()
定义: baselist.h:578
maxon::BaseList::GetCount
Int GetCount() const
定义: baselist.h:546
maxon::BaseList::Insert
ResultRef< T > Insert(Int position)
定义: baselist.h:675
maxon::end
MAXON_ATTRIBUTE_FORCE_INLINE auto end(COLLECTION &&c) -> decltype(c.End())
定义: foreach.h:360
maxon::BaseList::IsPopulated
MAXON_ATTRIBUTE_FORCE_INLINE Bool IsPopulated() const
定义: baselist.h:536
maxon::begin
MAXON_ATTRIBUTE_FORCE_INLINE auto begin(COLLECTION &&c) -> decltype(c.Begin())
定义: foreach.h:355
iferr_return
#define iferr_return
定义: resultbase.h:1434
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
maxon::BaseList::Begin
ConstIterator Begin() const
定义: baselist.h:1231
maxon::BaseList::Erase
ResultPtr< T > Erase(Int position, Int eraseCnt=1)
定义: baselist.h:872
maxon::BaseList::IsEmpty
MAXON_ATTRIBUTE_FORCE_INLINE Bool IsEmpty() const
定义: baselist.h:527
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
maxon::BaseList::Swap
void Swap(Iterator a, Iterator b)
定义: baselist.h:1184
maxon::BaseList::End
ConstIterator End() const
定义: baselist.h:1253
maxon::BaseList::Flush
void Flush()
Deletes all elements (same as Reset() for the BaseList).
定义: baselist.h:518
maxon::BaseList
定义: baselist.h:457

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1