Add( ) method (Collections)
- Last Updated: March 15, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Adds an element to the collection. Returns TRUE if the element was added successfully. Otherwise returns FALSE.
For a List<T>, the element is added to the end of the list.
For a SortedSet<T>, the element is
added to the set according to the comparer implementation (default or custom).
Return type: LOGICAL
Access: PUBLIC
Applies to: Progress.Collections.List<T> class, Progress.Collections.SortedSet<T> class
Syntax
|
- element
- The object to add to the collection.
Examples
For a code example showing Add() for a list,
see Progress.Collections.List<T> class.
For an code example showing Add() for a sorted set,
see Progress.Collections.SortedSet<T> class.
Notes
- Any iterators on the collection become invalid once
Add(),AddAll(),Clear(),Insert(),Remove(),RemoveAt(), orSet()are called, and you must get a new iterator to iterate over the collection. - For a
SortedSet<T>,Add()raises an error if:- the element does not implement Progress.Collections.IComparable<T> interface, if using the default comparer implementation.
- the element is not a valid object reference (including the unknown value), if using the default comparer.
- the comparer object specified via the specific constructor has become invalid.
- the comparer raises an error.
- Once an element is added to a sorted set, you must call
Remove()(to remove the element from the set) before you explicitly delete the object instance while still in use in the set; otherwise errors occur. - When an object-oriented ABL object is added to a collection, the reference count of the object is incremented so that it is not garbage collected while it remains in the collection.