Array Collection (PRIM_ACOL)

Sequential collection of objects accessible via an index

Ancestors - Collection (PRIM_COLL) Object (PRIM_OBJT)

Details

Array collections are a dynamically sized, ordered collection of components.
 
The features of the array component are positional in nature, in reference to a given index or to the beginning or end of the list. Indexing is always relative to 1.
 
Array collections and List collections are very similar in nature, the only real difference being the way they handle memory allocation in Windows.

Examples

Defining an array collection. This collection stores instances of a user defined customer data object.
Define_Com Class(#Prim_Acol<#Customer>) Name(#Customers)
Collection items can be created by assigning them to an existing reference or creating a new one as below.
#Customers.Insert((*New #Customer))
Collection items can be accessed by their position in the collection.
#Customers<123>.CustomerName := #CustomerName
All collection items can be addressed as follows. Here, all the customers in the collection are having a property value incremented.
#Customers<>.CreditLimit += 1000
The FOR command can also be used to iterate over the collection contents. The items will be returned in the order they are stored in the collection.
For each(#Customer) in (#Customers)
   ...
Endfor
To monitor for an event from any instance in the collection, <> can be appended to an EVTROUTINE. The COM_SENDER parameter will provide access to the instance firing the event.
 
In this example, a changed event on the customer instances is monitored.
Evtroutine Handling(#Customers<>.Changed) Com_Sender(#Sender)
 
   #Com_owner.AddEvent(("&1 changed").Substitute(#Sender.CustomerName))
 
Endroutine

Properties

NameDescription
AllowsDuplicatesAllowsDuplicates indicates whether the collection allows duplicates Inherited from Collection (PRIM_COLL)
CollectsThe class of object to be collected
ComponentClassNameComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)
ComponentMembersComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)
ComponentPatternNameComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)
ComponentTagGeneric space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)
ComponentTypeComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)
ComponentTypeNameComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)
FirstReference to the first item in the collection
IndexOfIndexOf returns the index number of an item in a collection
IsEmptyIsEmpty indicates whether the collection contains any items. Inherited from Collection (PRIM_COLL)
IsOrderedIsOrdered indicates whether the collection is ordered. Inherited from Collection (PRIM_COLL)
ItemAllows access to a specific item in the collection
ItemCountItemCount is the number of items in a collection Inherited from Collection (PRIM_COLL)
LastLast is the Last item in a collection
NameName identifies the component Inherited from Object (PRIM_OBJT)
OwnerOwner owns this component Inherited from Object (PRIM_OBJT)
ParentThe component instance to which this instance is attached. The visual container for a control or the collector of a set of child instances Inherited from Object (PRIM_OBJT)

Events

NameDescription
CreateInstanceCreateInstance is signalled when an instance of a component is created Inherited from Object (PRIM_OBJT)
DestroyInstanceDestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from Object (PRIM_OBJT)
IsEqualFired whenever the collection needs to compare two items
Object, Subject, Equal

Methods

NameDescription
CalculateHashCalculateHash calculates a hash value Inherited from Collection (PRIM_COLL)
Result, Value
ContainsDoes the supplied instance exist in the collection?
Result, Object
CreateAccessorCreateAccessor creates an accessor component that provides read-only access to the collection
Result
CreateIteratorCreateIterator method creates an iterator component that enables iteration through the collection
Result
InsertInsert adds an item to a collection
Item
InsertAfterInsertAfter adds an item to a collection after a specified position
Item, Index
InsertBeforeInsertBefore adds an item to a collection before a specified item
Item, Index
InsertFirstInsertFirst adds an item in the beginning of the collection
Item
InsertLastInsertLast adds an item in the end of the collection
Item
OccurrencesOfFind the number of occurrences of an instance in the collection
Result, Object
RemoveRemove method removes an item
Result, Object
RemoveAllRemoveAll removes all items in the collection
RemoveAtRemoves the item at the specified position
Result, Index
RemoveFirstRemove the first item from the collection
Result
RemoveLastRemove the last item from the collection
Result
ReplaceAtReplace the instance at the specified position with a different object
Result, Item, Index

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2