Skip to main content

%Collection.AbstractListOfObj

Class %Collection.AbstractListOfObj Extends %Collection.AbstractList [ System = 2 ]

A list collection represents a list of data type elements, each of which is associated with a numeric position in the list. The first element in the list is stored at position 1.

The %Collection.AbstractList class provides the basic functionality of the various list collection classes.

The non-abstract list classes derived from %AbstractList include %ListOfDataTypes, %ListOfObjects, %Collection.ListOfObj and %Collection.ListOfDT. You can use a list object as follows: Set list=##class(%ListOfDataTypes).%New() ; add items to the list Do list.Insert("Harpo") Do list.Insert("Groucho") Do list.Insert("Chico") Do list.Insert("Karl") ; iterate over contents of list For i=1:1:list.Count() Write list.GetAt(i),!

Methods

Find

Method Find(element As %ObjectIdentity, key As %Integer) As %String [ Abstract ]

Starting from, but not including, position key, Find finds the next element in the list with value equal to element. If key is a null string, Find starts at the beginning of the list.

Find returns the position of the found element or null string ("") if no element was found.

FindOref

Method FindOref(oref As %RegisteredObject, key As %Integer = "", id As %String = "") As %String [ Abstract ]

Starting from, but not including, location key, finds the next element in the array whose Oref value equals oref.

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

FindOref returns the key associated with the found element or null string ("") if no element is found. Unswizzled references are compared to oref.%Oid() and if equal, swizzling will occur.

GetAt

Method GetAt(key As %Integer = 0) As %RegisteredObject [ Abstract ]

Finds and returns the value of the element at position key in the list.

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

GetNext

Method GetNext(ByRef key As %Integer) As %RegisteredObject [ Abstract ]

Finds and returns the value of the element at the position after key in the list. If key is a null string (""), it returns the value of the first element in the list.

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

GetPrevious

Method GetPrevious(ByRef key As %Integer) As %RegisteredObject [ Abstract ]

Finds and returns the value of the element at the position before key in the list. If key is a null string (""), it returns the value of the last element in the list.

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

Insert

Method Insert(element As %RegisteredObject) As %Status [ Abstract ]

Inserts an element with value element at the end of the list.

Returns a %Status value indicating success or failure.

InsertAt

Method InsertAt(element As %RegisteredObject, key As %Integer) As %Status [ Abstract ]

Inserts an element with value element at position key.

To make room for the new element, the elements previously at or following position key are moved up by one position.

key must be in the following range: 1 <= key <= Count() + 1 Returns a %Status value indicating success or failure.

RemoveAt

Method RemoveAt(key As %Integer, Output success As %Boolean) As %ObjectIdentity [ Abstract ]

Removes the element at position key in the list. The elements following position key are moved to fill in the resulting gap.

RemoveAt returns the value of the removed element or null string ("") if no element was removed. It also has a success output argument that returns true if the item was removed and false if it was not.

SetAt

Method SetAt(element As %RegisteredObject, key As %Integer) As %Status [ Abstract ]

Sets the value of the element at position key to element.

Returns a %Status value indicating success or failure.

FindObjectId

Method FindObjectId(id As %String, key As %Integer) As %String [ Abstract ]

Starting from, but not including, position key, FindObjectId finds the next element in the list whose ObjectId equals id. If key is a null string, Find starts at the beginning of the list.

Find returns the position of the found element or null string ("") if no element was found.

GetObjectAt

Method GetObjectAt(key As %Integer, force As %Integer = 0) As %ObjectIdentity [ Abstract ]

Finds and returns the OID value referring to the object at position key in the list.

Returns the value of the element at location key or null string ("") if no element is found.

GetObjectIdAt

Method GetObjectIdAt(key As %Integer, force As %Integer = 0) As %String [ Abstract ]

Finds and returns the ID value referring to the object at position key in the list.

Returns the value of the element at location key or null string ("") if no element is found.

GetObjectNext

Method GetObjectNext(ByRef key As %Integer) As %ObjectIdentity [ Abstract ]

Finds and returns the OID value referring to the object at the position after key in the list. If key is a null string (""), it returns the OID value of the first element in the list.

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

GetObjectIdNext

Method GetObjectIdNext(ByRef key As %Integer) As %String [ Abstract ]

Finds and returns the ID value referring to the object at the position after key in the list. If key is a null string (""), it returns the ID value of the first element in the list.

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

GetObjectPrevious

Method GetObjectPrevious(ByRef key As %Integer) As %ObjectIdentity [ Abstract ]

Finds and returns the OID value referring to the object at the position before key in the list. If key is a null string (""), it returns the OID value of the last element in the list.

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

GetObjectIdPrevious

Method GetObjectIdPrevious(ByRef key As %Integer) As %String [ Abstract ]

Finds and returns the ID value referring to the object at the position before key in the list. If key is a null string (""), it returns the ID value of the last element in the list.

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

InsertObject

Method InsertObject(oid As %ObjectIdentity) As %Status [ Abstract ]

Inserts an element with OID value oid at the end of the list.

Returns a %Status value indicating success or failure.

InsertObjectId

Method InsertObjectId(id As %String) As %Status [ Abstract ]

Inserts an element with ID value id at the end of the list.

Returns a %Status value indicating success or failure.

InsertObjectAt

Method InsertObjectAt(oid As %ObjectIdentity, key As %Integer) As %Status [ Abstract ]

Inserts an element with OID value oid at position key.

To make room for the new element, the elements previously at or following position key are moved up by one position.

key must be in the following range: 1 <= index <= Count() + 1 Returns a %Status value indicating success or failure.

InsertObjectIdAt

Method InsertObjectIdAt(id As %String, key As %Integer) As %Status [ Abstract ]

Inserts an element with ID value id at position key.

To make room for the new element, the elements previously at or following position key are moved up by one position.

key must be in the following range: 1 <= index <= Count() + 1 Returns a %Status value indicating success or failure.

SetObjectAt

Method SetObjectAt(oid As %ObjectIdentity, key As %Integer) As %Status [ Abstract ]

Sets the OID value of the element at position key to oid.

Returns a %Status value indicating success or failure.

SetObjectIdAt

Method SetObjectIdAt(id As %String, key As %Integer) As %Status [ Abstract ]

Sets the ID value of the element at position key to id.

Returns a %Status value indicating success or failure.