Class wwCollection

The base wwCollection class allows adding items as single items. The collection is purely accessed by a numeric indexer.

The collection internally manages an aItems array which can also be accessed directly for performance if necessary.

loCol = CREATEOBJECT("wwCollection")

loCol.Add("This is Item1")
loCol.Add("This is Item2")

? loCol.Count           && 2
? loCol.Item(1)         && This is Item1
? loCol.Item(2)         && This is Item2

? loCol.aItems[1]       && This is Item1
? loCol.aItems[2]       && This is Item2


? loCol.Item(4)         && .NULL.

loCol.Remove(2)
? loCol.Count           && 1
Custom

Class Members

MemberDescription

Add

Adds an item to the Collection.

If RequireUniqueItems=.T. and a value exists already the original item is left without adding a new value, which is slightly slower.

o.Add(Value)

Clear

Clears all of the collection's items.

o.Clear()

Find

Finds an item by value.

Note: Only finds the first match.

o.Find(lvItem)

FindIndex

Finds the first matching item in the array by its value and returns the index. If not found 0 is returned.

Collections are expected to contain items of the same type or else you will get type mismatch errors.

String values are searched in a case insensitive manner.

o.FindIndex(lvItem)

InsertAt

Inserts an item at the specified index position. Items are inserted before the item specified.

o.InsertAt(Position,Value)

Item

Returns an item from the collection by in integer index value.

If the item doesn't exist null is returned, or if llThrowError=.T. an error is generated.

o.Item(Index, llThrowError)

Remove

Removes an item from the collection by its index value.

o.Remove(Index, llRemoveByValue)

Set

o.Set(lvValue)

UpdateItem

Updates an item in the collection at a specific location.

o.UpdateItem(lnIndex,lvValue)

aItems[]

The internally maintained array of items added. This array is one dimensional and contains only the values added.

Count

The count of items in this collection.

RequireUniqueItems

When .T. insures that all items in the collections are unique when added.


© West Wind Technologies, 2023 • Updated: 11/10/18
Comment or report problem with topic