Set Collection (PRIM_SCOL)

Unordered collection of components that cannot contain duplicates

Ancestors - Collection (PRIM_COLL)Object (PRIM_OBJT)

Details

Set collections provide an ordered collection of components that does not allow duplicates.

The features of the Set 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.

Set collections and Array collections are very similar in nature.

Examples

Defining a Set collection. This collection stores instances of a user defined customer data object.

     Define_Com Class(#Prim_Scol<#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

Name

Description

AllowsDuplicates

AllowsDuplicates indicates whether the collection allows duplicates Inherited from Collection (PRIM_COLL)

Collects

The class of object to be collected

ComponentClassName

ComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)

ComponentMembers

ComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)

ComponentPatternName

ComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)

ComponentTag

Generic space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)

ComponentType

ComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)

ComponentTypeName

ComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)

IsEmpty

IsEmpty indicates whether the collection contains any items. Inherited from Collection (PRIM_COLL)

IsOrdered

IsOrdered indicates whether the collection is ordered. Inherited from Collection (PRIM_COLL)

Item

Provides access to a particular item in a collection

ItemCount

ItemCount is the number of items in a collection Inherited from Collection (PRIM_COLL)

Name

Name identifies the component Inherited from Object (PRIM_OBJT)

Owner

Owner owns this component Inherited from Object (PRIM_OBJT)

Parent

The 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

Name

Description

CreateInstance

CreateInstance is signalled when an instance of a component is created Inherited from Object (PRIM_OBJT)

DestroyInstance

DestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from Object (PRIM_OBJT)

Hash

Hash is triggered when an integer value needs to be determined to organize the collection

Subject, Hash

IsEqual

Fired whenever the collection needs to compare two items

Object, Subject, Equal

Methods

Name

Description

CalculateHash

CalculateHash calculates a hash value Inherited from Collection (PRIM_COLL)

Result, Value

Contains

Does the supplied instance exist in the collection?

Result, Object

CreateAccessor

CreateAccessor creates an accessor component that provides read-only access to the collection

Result

CreateIterator

CreateIterator method creates an iterator component that enables iteration through the collection

Result

Find

Find method returns a reference to a item in a collection

Result, Object

Insert

Insert adds an item to a collection

Result, Item

Remove

Remove method removes an item

Result, Object

RemoveAll

RemoveAll removes all items in the collection


See also

All Component Classes

Technical Reference

  • No labels