Skip to main content

%Collection.AbstractArrayOfDT

abstract class %Collection.AbstractArrayOfDT extends %Collection.AbstractArray

An array collection represents an array of data type elements, each of which is associated with a unique key value. Keys can have any value, string or numeric.

The %Collection.AbstractArrayOfDT class provides the basic functionality of the various array collection classes.

The non-abstract array classes derived from %AbstractArrayOfDT include %ArrayOfDataTypes, %ArrayOfObjects, %Collection.ArrayOfObj and %Collection.ArrayOfDT.

You can use an array object as follows:

  Set arr=##class(%ArrayOfDataTypes).%New()
  
  ; place items into the array
  Do arr.SetAt("red","color")
  Do arr.SetAt("large","size")
  Do arr.SetAt("expensive","price")
  
  ; iterate over contents of array
  Set key=""
  For  Set value=arr.GetNext(.key) Quit:key=""  Write key,":",value,!
  

Method Inventory

Methods

abstract method Find(element As %String, key As %String) as %String
Starting from, but not including, location key, finds the next element in the array with value equal to element.

If key is a null string (""), the search starts at the beginning of the array.

Find returns the key associated with the found element or null string ("") if no element is found.

abstract method GetAt(key As %String = "") as %String
Finds and returns the value of the element associated with key.

GetAt returns the value of the element associated with key or null string ("") if no element is found.

abstract method GetNext(ByRef key As %String) as %String
Finds and returns the value of the element at the location after key in the array. If key is a null string (""), it returns the value of the first element in the array.

The value of key, which is passed by reference, is updated to the key value of the returned element or null string ("") if key is at the end of the array.

abstract method GetPrevious(ByRef key As %String) as %String
Finds and returns the value of the element at the location before key in the array. If key is a null string (""), it returns the value of the last element in the array.

The value of key, which is passed by reference, is updated to the key value of the returned element or null string ("") if key is at the beginning of the array.

abstract method RemoveAt(key As %String) as %String
Removes the element associated with key in the array.

RemoveAt returns the value of the removed element or null string ("") if no element was removed.

abstract method SetAt(element As %String, key As %String) as %Status
Sets the value of the element associated with key to element.

Returns a %Status value indicating success or failure.

Inherited Members

Inherited Methods

Subclasses

FeedbackOpens in a new tab