Synergex.SynergyDE.Collections.ArrayList

Dynamic collection class with 1-based indexing

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
namespace Synergex.SynergyDE.Collections
public class ArrayList

The Synergex.SynergyDE.Collections.ArrayList class is a dynamic collection class with 1-based indexing (which means the index of the first element is 1). See Variable references for more information about array references and Defining arrays for information about accessing members of your array list.

Constructors

ArrayList

public ArrayList()

Initializes a new instance of ArrayList with a default capacity of 16 elements.

or

ArrayList(capacity)

Initializes a new instance of ArrayList with the specified initial capacity (i4, the number of elements the new array list can store).

Properties

Capacity

public virtual Capacity

Returns or sets the number of elements that the array list can contain. (int)

Count

public virtual Count

Returns the number of elements that are actually in the array list.

Indexer

public virtual Indexer(index)

Returns the element in the array that is located at index (1-based, int). (@*)

Methods

Add

public virtual Add(object), int

Adds the specified element to the end of the array list and returns the index at which that object was added. Object can be null. (@*)

Clear

public virtual Clear(), void

Removes all elements from the array list. Sets count to zero and releases references to other objects.

Clone

public virtual Clone(), @Object

Returns a new array list that is a shallow copy of objects in the current array list. A shallow copy includes only the elements in the array list (not the objects that any references refer to).

IndexOf

IndexOf() determines equality by calling the Equals() method of the ArrayList element type.

public virtual IndexOf(object), int

Returns the first 1-based index position for the specified object in the entire array list. Object can be null. (@*)

or

public virtual IndexOf(object, startindex), int

Returns the first 1-based index position for the specified object (@*) within the range of elements between startindex (int) and the last element. Object can be null. (@*)

or

public virtual IndexOf(object, startindex, count), int

Returns the first 1-based index position for the specified object (@*) within the range of elements starting at startindex (int) and continuing for the number of elements specified in count (int). Object can be null.

Insert

public virtual Insert(index, object), void

Inserts an the specified object (@*) into the array list at the specified 1-based index (int). Object can be null. 

LastIndexOf

LastIndexOf() determines equality by calling the Equals() method of the ArrayList element type.

public virtual LastIndexOf(object), int

Returns the last 1-based index position for the specified object in the entire array list. Object (@*) can be null. 

or

public virtual LastIndexOf(object, startindex), int

Returns the last 1-based index position for the specified object (@*) within the range of elements between startindex (int) and, working backward, the first element.

or

public virtual LastIndexOf(object, startindex, count), int

Returns the last 1-based index position for the specified object (@*) within the range of elements beginning at startindex (int) and continuing backward for the number of elements specified in count (int).

RemoveAt

public virtual RemoveAt(index), void

Removes the element at the specified 1-based index (int). The elements that follow are moved up to occupy the vacant spot.

Examples

import Synergex.SynergyDE.Collections

structure syntxtrec
    recdata        ,a218
endstructure

main

proc
    begin
      ;Declare variable as ArrayList
      data al               ,@ArrayList
      data fchn      ,int
      data ttchn     ,int
      data counter   ,int
      data numrecs   ,int
      ;Structfield based on structure syntxtrec 
      data sf              ,syntxtrec
      ;Object type of structfield
      data sfO             ,@syntxtrec

      open(fchn =%syn_freechn, I:I, "DBLDIR:syntxt.ism")
      open(ttchn=%syn_freechn, O, "TT:")

      ;Get the number of records in the syntxt ISAM file
      numrecs = %isinfo(fchn, "NUMRECS")

      ;Create arraylist with capacity of number of records in syntxt
      al = new arraylist(numrecs)

      ;Populate the ArrayList with records from the syntxt ISAM file
      for counter from 1 thru numrecs
        begin
          reads(fchn, sf, eof)
          ;Must cast as structfield object to add structfield to arraylist
          ;as ArrayList may only contain objects
          al.Add((@syntxtrec)sf)
        end
eof,
    foreach sfO in al              ;Must use object type to iterate through ArrayList in foreach loop
      begin
        writes(ttchn, %atrim(sfO)) ;Write out value
      end
      ;Clean up
      al = ^NULL
      close fchn, ttchn
    end
endmain