Skip to main content

%Collection.AbstractList

abstract class %Collection.AbstractList extends %Collection.AbstractIterator

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),!
  

Method Inventory

Methods

method %IsNull() as %Boolean
A collection is null if it does not contain any elements
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.

abstract method Clear() as %Status
Clears the contents of the list.

Returns a %Status value indicating success or failure.

abstract method Count() as %Integer
Returns the number of elements contained in the list.
abstract method Find(element As %RawString, key As %Integer) as %String
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.

abstract method GetAt(key As %Integer = 0) as %RawString
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.

abstract method GetNext(ByRef key As %Integer) as %RawString
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.

abstract method GetPrevious(ByRef key As %Integer) as %RawString
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.

abstract method Insert(element As %RawString) as %Status
Inserts an element with value element at the end of the list.

Returns a %Status value indicating success or failure.

abstract method InsertAt(element As %RawString, key As %Integer) as %Status
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.
abstract method InsertList(inslist As %RawString) as %Status
Inserts a list with value inslist at the end of the list.

Returns a %Status value indicating success or failure.

abstract method InsertOrdered(element As %RawString) as %Status
Inserts an element with value element into the list at the correct ordered position. The elements in the list are shifted to accommodate the new element as necessary.

Returns a %Status value indicating success or failure.

classmethod LogicalToOdbc(val As %String = "", delim As %String = ",", class As %String = "", method As %String = "") as %String
Converts the serial state of this list object to a delimited string using "," as a delimiter.
Finds and returns the index value of the element at the location following key in the list. If key is a null string (""), then Next returns the position of the first element in the list (1).
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 "," as a delimiter.
Finds and returns the index value of the element at the location preceding key in the list. If key is a null string (""), then Previous returns the position of the last element in the list.
abstract method RemoveAt(key As %Integer) as %RawString
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.

abstract method SetAt(element As %RawString, key As %Integer) as %Status
Sets the value of the element at position key to element.

Returns a %Status value indicating success or failure.

Subclasses

FeedbackOpens in a new tab