%Collection.AbstractArray
Class %Collection.AbstractArray Extends %Collection.AbstractIterator [ Abstract, ClientDataType = HANDLE, System = 2 ]
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.AbstractArray class provides the basic functionality of the various array collection classes.
The non-abstract array classes derived from %AbstractArray 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,!
Parameters
ELEMENTTYPE
Parameter ELEMENTTYPE As STRING = "%String";
The type (class name) of the elements stored in the collection.
Methods
BuildValueArray
ClassMethod BuildValueArray(serialized As %Binary, array As %Binary) As %Status
Constructs array(key)=value for each element in the serialval value.
Returns a %Status value indicating success or failure.
%IsNull
Method %IsNull() As %Boolean [ CodeMode = expression ]
A collection is null if it does not contain any elements
Clear
Method Clear() As %Status [ Abstract ]
Clears the contents of the array.
Returns a %Status value indicating success or failure.
Count
Method Count() As %Integer [ Abstract ]
Returns the number of elements contained in the array.
IsDefined
Method IsDefined(key As %String) As %Boolean [ Abstract ]
Returns true (1) if a value is defined at location key, otherwise false (0).
Define
Method Define(key As %String) As %Boolean [ Abstract, Deprecated ]
This method is deprecated.
Please use IsDefined instead.
Find
Method Find(element As %RawString, key As %String) As %String [ Abstract ]
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.
GetPrevious
Method GetPrevious(ByRef key As %String) As %RawString [ Abstract ]
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.
Previous
Method Previous(key As %String = "") As %String [ Abstract ]
Finds and returns the key value of the element at the location preceding key in the array. If key is a null string (""), then Previous returns the key value for the last element in the array.
RemoveAt
Method RemoveAt(key As %String) As %RawString [ Abstract ]
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.
SetAt
Method SetAt(element As %RawString, key As %String) As %Status [ Abstract ]
Sets the value of the element associated with key to element.
Returns a %Status value indicating success or failure.
LogicalToOdbc
ClassMethod LogicalToOdbc(val As %String = "", delim As %String = ",", class As %String = "", method As %String = "") As %String
Converts the serial state of this array object to a delimited string using delim as a delimiter.
OdbcToLogical
ClassMethod OdbcToLogical(val As %String = "", delim As %String = ",", class As %String = "", method As %String = "") As %String
Converts the value of an incoming delimited string to a serialized state using delim as a delimiter.