While the ICustomBasicList interface, which was introduced in the
madBasic unit, is only a base interface which you can't use directly,
here comes a full list interface, which can store any IBasic items.
Since all my interfaces are based on IBasic that means that you can
simply store all my interfaces in this list. You can even store other lists
in this list. For a full list of methods and properties look at the
IBasicList Reference.
|
type IBasicList = interface (ICustomBasicList) ['{0DDE44C0-71EB-11D3-A52D-00005A180D69}'];
|
|
When creating a new "BasicList", you can either create it emptily, or you can
right away fill it with some items:
|
function NewBasicList : IBasicList; overload;
function NewBasicList (const items: array of IBasic) : IBasicList; overload;
|
|
The "Items" property gives you read and write access to the items of the list:
|
property IBasicList.Items [index: integer] : IBasic;
|
|
With the following property you can get and even directly set the size of
the array which holds the items. That means when you set the array to a size
which is smaller then IList.ItemCount you're deleting items from the
list. Setting the "Capacity" to zero consequently deletes all items from the
list.
|
property IBasicList.Capacity : integer;
|
|
Use the methods "AddItem(s)" to add one or more items to our list. The
method "InsertItem" inserts the specified item at the specified position.
This makes sense only for a non sorted list, of course. The result of all 3
methods is the new index of the (first) added item.
|
function IBasicList.AddItem (const item : IBasic ) : integer;
function IBasicList.AddItems (const items: array of IBasic) : integer;
function IBasicList.InsertItem (const item : IBasic;
index : integer = 0 ) : integer;
|
|
You can either delete an item from the list by giving in it's index or by
giving in the item itself. With the method "Clear" you can delete all items
at once.
|
function IBasicList.DeleteItem ( index : integer) : boolean; overload;
function IBasicList.DeleteItem (const item : IBasic ) : boolean; overload;
procedure IBasicList.Clear;
|
|
The following method simply swaps the position of two items in the list. This
makes sense only for non sorted lists, or course.
|
function IBasicList.Swap (index1, index2: integer) : boolean;
|
|