PackedIndexLists (struct)

The PackedIndexLists allows to store multiple double-linked lists of UInt32 values into a single memory buffer.

/note List and element keys are not safe-guarded; a wrong usage will lead to unexpected results.

/example require Containers;

function printList( PackedIndexLists lists, PackedIndexListKey listKey ) { report(“Elements:”); PackedIndexListKey key = listKey; UInt32 index; while( lists.getNextIndexAndIncrement( key, index ) ) report(” ” + index ); }

operator entry(){

PackedIndexLists lists;

PackedIndexListKey list1 = lists.createList(); lists.listAddIndex( list1, 3 );

//Keep a key for element 9, as we will remove it later PackedIndexListElementKey element9 = lists.listAddIndex( list1, 9 );

PackedIndexListKey list2 = lists.createList(); lists.listAddIndex( list2, 1 ); lists.listAddIndex( list2, 2 );

lists.listAddIndex( list1, 8 );

lists.listAddIndex( list2, 5 );

//Remove ‘9’ from list1 lists.removeListElement( element9 );

printList( lists, list1 ); printList( lists, list2 ); } /endexample

PackedIndexLists PackedIndexLists PackedIndexLists

Methods

  PackedIndexLists ( in PackedIndexLists other )
  PackedIndexLists ()
  clearAll ! ( in Boolean deallocate )
  clearList ! ( in PackedIndexListKey listKey )
PackedIndexLists clone ? ()
PackedIndexListKey createList ! ()
  deleteList ! ( in PackedIndexListKey listKey )
String getListDesc ? ( in PackedIndexListKey listKey )
Size getListSize_slow ? ( in PackedIndexListKey listKey )
Boolean getNextIndexAndIncrement ? ( io PackedIndexListElementKey elementKey, io UInt32 index )
PackedIndexListElementKey listAddIndex ! ( in PackedIndexListKey listKey, in UInt32 index )
Boolean listIsEmpty ? ( in PackedIndexListKey listKey )
PackedIndexListElementKey moveElementToList ! ( in PackedIndexListElementKey elementKey, in PackedIndexListKey targetListKey )
  removeListElement ! ( in PackedIndexListElementKey elementKey )

Methods in detail

PackedIndexLists ( in PackedIndexLists other )

copy constructor



PackedIndexLists.clearAll! ( in Boolean deallocate )

clears all managed lists.


PackedIndexLists.clearList! ( in PackedIndexListKey listKey )

empties an existing list


PackedIndexLists PackedIndexLists.clone? ()

clone method


PackedIndexListKey PackedIndexLists.createList! ()

returns a new list. A key for identifying the list is returned.


PackedIndexLists.deleteList! ( in PackedIndexListKey listKey )

removes a complete list from the PackedIndexLists


String PackedIndexLists.getListDesc? ( in PackedIndexListKey listKey )

returns a string containing the description of a given list


Size PackedIndexLists.getListSize_slow? ( in PackedIndexListKey listKey )

returns the size of a list.

注釈

This requires a full traversal of the list.


Boolean PackedIndexLists.getNextIndexAndIncrement? ( io PackedIndexListElementKey elementKey, io UInt32 index )

If true is returned, this retrieves the next UInt32 element of the list and goes to the next one. If false is returned, there are no other elements. See PackedIndexLists for an example of usage.

index Stored UInt32 value
elementKey List iterator (will be incremented to point to the next element)


PackedIndexListElementKey PackedIndexLists.listAddIndex! ( in PackedIndexListKey listKey, in UInt32 index )

adds an index to an existing list.


Boolean PackedIndexLists.listIsEmpty? ( in PackedIndexListKey listKey )

returns true if a given list is empty


PackedIndexListElementKey PackedIndexLists.moveElementToList! ( in PackedIndexListElementKey elementKey, in PackedIndexListKey targetListKey )

move one element from an existing list to another one


PackedIndexLists.removeListElement! ( in PackedIndexListElementKey elementKey )

removes a list element. After the removal, the element key is no longer valid, however other elements of the list remain valid.