Constructors: NewArrayList

NewArrayList

Creates a new ArrayList object with the specified settings.



 Public Function NewArrayList(
	  Optional ByVal Comparer As IComparer,
	  Optional ByRef Source As Variant ) As ArrayList

Parameters

Comparer
[ByVal] Optional. IComparer. A comparer to be used for searching and sorting items in the list.
Source
[ByRef] Optional. Variant. A collection to initialize the list with. Count will reflect the number of items added.

Return Values

ArrayList -  A new ArrayList object.

Remarks

Sometimes the comparison of two items in the list cannot be accomplished by the default comparer that ArrayList uses. Cases like this may be when using different datatypes, UDTs, or objects that do not implement IComparable. In cases such as these, a custom comparer object may be supplied during the construction of an ArrayList. This comparer will be used as the default comparer for methods that require comparing items.

An ArrayList can be initialized with a default set of items. This is the same as creating a new ArrayList and using AddRange to add the items.

ArrayList accepts a VBA.Collection, ICollection, and an array as a list of items to initialize the new ArrayList to.

Example

 Dim MyItems(10) As Long

 Set list = NewArrayList(New MyComparer, MyItems)
 
This will create a new ArrayList that uses MyComparer as the default comparer for the items. The ArrayList is also initialized with an array of Longs. The fully initialized ArrayList will have a count of 11 items, each item being a Long datatype with the value of 0.

See Also

Project CorLib Overview

Class Constructors Overview

ArrayList

IComparer