# IIntfCollection/IStrCollection/ICollection

## Unit

DCL_intf

## Inheritance

Base interface

inherited by

- IIntfList/IStrList/IList
- IIntfSet/IStrSet/ISet

## Methods

### IIntfCollection

`function Add(AObject: IInterface): Boolean;
function AddAll(ACollection: IIntfCollection): Boolean;
procedure Clear;
function Contains(AObject: IInterface): Boolean;
function ContainsAll(ACollection: IIntfCollection): Boolean;
function Equals(ACollection: IIntfCollection): Boolean;
function First: IIntfIterator;
function IsEmpty: Boolean;
function Last: IIntfIterator;
function Remove(AObject: IInterface): Boolean;
function RemoveAll(ACollection: IIntfCollection): Boolean;
function RetainAll(ACollection: IIntfCollection): Boolean;
function Size: Integer;
`

### IStrCollection

`function Add(const AString: string): Boolean;
function AddAll(ACollection: IStrCollection): Boolean;
procedure Clear;
function Contains(const AString: string): Boolean;
function ContainsAll(ACollection: IStrCollection): Boolean;
function Equals(ACollection: IStrCollection): Boolean;
function First: IStrIterator;
function IsEmpty: Boolean;
function Last: IStrIterator;
function Remove(const AString: string): Boolean;
function RemoveAll(ACollection: IStrCollection): Boolean;
function RetainAll(ACollection: IStrCollection): Boolean;
function Size: Integer;
`

### ICollection

`function Add(AObject: TObject): Boolean;
function AddAll(ACollection: ICollection): Boolean;
procedure Clear;
function Contains(AObject: TObject): Boolean;
function ContainsAll(ACollection: ICollection): Boolean;
function Equals(ACollection: ICollection): Boolean;
function First: IIterator;
function IsEmpty: Boolean;
function Last: IIterator;
function Remove(AObject: TObject): Boolean;
function RemoveAll(ACollection: ICollection): Boolean;
function RetainAll(ACollection: ICollection): Boolean;
function Size: Integer;
`

## Description

A collection is an entity that handles a group of objects. This is the base interface for List and Set.

Method | Description
--- | ---
Add | Add AObject at the end of the collection. Return True if the method succeeds.
AddAll | Add all objetcs from ACollection at the end of the collection. Return True if the method succeeds.
Clear | Clear all objects contained in the collection.
Contains | Return True if the collection contains AObject.
ContainsAll | Return True if the collection contains all objects of ACollection.
Equals | Return True if all objects of the collection are equal to all objects of ACollection.
First | Return a new Iterator from the begin of the collection.
IsEmpty | Return True if the collection does not contain any objects.
Last | Return a new Iterator from the end of the collection.
Remove | Remove AObject from the collection. Return True if the method succeeds.
RemoveAll | Remove all objects from the collection contained in ACollection. Return True if the method succeeds.
RetainAll | Remove all objects from the collection except all objects contained in ACollection. Return True if the method succeeds.
Size | Return the number of objects contained in the collection.

## Implemented By

- ArrayList
- ArraySet
- HashSet
- LinkedList
- Vector