NAME

WWWdb::List - Lists for WWWdb


SYNOPSIS

 use WWWdb::List;

 $oList     = List->new([FillAtInsert => $bFill]);

 $cResult   = $oList->Append($cValue);

 $cResult   = $oList->Get($iIndex);

 $cResult   = $oList->Set($iIndex, $cValue);

 $cResult   = $oList->Insert($iIndex, $cValue);

 $cResult   = $oList->Delete($iIndex);

 $iResult   = $oList->Count();


DESCRIPTION


The List class

Perl is a good language for list-manipulation. Neverthless I wished some funktionality for imbedded class-elements in list-form. That was the main reason, for developing this class.


Note

none


Class Methods

new

 $oList     = List->new([FillAtInsert => $bFill]);

Create a new empty list. If the insertion of an element with an index greater then the actual number of elements should be done, you have to decide, if the elements between have to be created, or not. This can be done with the FillAtInsert-argument. True means, that elements with the value undef will be inserted. Otherwise the new element will be appended to the list.

Append

 $cResult   = $oList->Append($cValue);

Appends the value cValue at the end of the list. The appended value will be returned.

Get

 $bResult   = $oList->Get($iIndex);

Returns the element with the Index iIndex. Negative numbers take elements from the end of the list, like in Perl.

Set

 $cResult   = $oList->Set($iIndex, $cValue);

Sets the value of the element with the Index iIndex. Negative numbers will use elements from the end of the list, like in Perl. The value, that has been set will be returned.

See also the attribute FillAtInsert.

Insert

 $cResult   = $oList->Insert($iIndex, $cValue);

Works like Set, but inserts the value into the list. This means, that all values with a greater index will be shifted.

See also the attribute FillAtInsert.

Delete

 $cResult   = $oList->Delete($iIndex);

Deletes the element at Index iIndex. The deleted element will be returned.

Count

 $iResult   = $oList->Count();

Returns the number of elements, the list contains.


Class Attributes

Name

 $bFill = $oList->getFillAtInsert();
 $oList->setFillAtInsert($bFill);

If empty space should be filled at the insertion of elements, then this attribute should be set.