Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

Delphi RTL types used by TArrayUtils

Project: Array Utilities Unit

Applies to: ~>0.1

This page contains brief descriptions of the Delphi run time library types used by TArrayUtils methods.

Function references

TComparison<T> function reference

Unit: System.Generics.Defaults

type
    TComparison<T> = reference to function(const Left, Right: T): Integer;

A function of this type can be passed to various TArrayUtils methods that compare values of type T.

The function must be implemented to return 0 if Left = Right, a negative value if Left < Right and a positive value if Left > Right.

TEqualityComparison<T> function reference

Unit: System.Generics.Defaults

type
    TEqualityComparison<T> = reference to function(const Left, Right: T): Boolean;

A function of this type can be passed to various TArrayUtils methods that test values of type T for equality.

The function must be implemented to return True if Left = Right or False if LeftRight.

Interfaces

IComparer<T> interface

Unit: System.Generics.Defaults

type
  IComparer<T> = interface
    function Compare(const Left, Right: T): Integer;
  end;

An instance of an object supporting this interface can be passed to various TArrayUtils methods that compare values of type T.

The Compare method must be implemented to return 0 if Left = Right, a negative value if Left < Right and a positive value if Left > Right.

IEqualityComparer<T> interface

Unit: System.Generics.Defaults

type
  IEqualityComparer<T> = interface
    function Equals(const Left, Right: T): Boolean;
    function GetHashCode(const Value: T): Integer;
  end;  

An instance of an object supporting this interface can be passed to various TArrayUtils methods that test values of type T for equality.

The Equals method must be implemented to return True if Left = Right or False if LeftRight.

The Hash method is not used by any TArrayUtils method, and so the quality of the returned hash code does not matter. In circumstances where it is certain that the Hash method will never be called then 0 can be returned.

Methods

TComparer<T>.Default class method

Unit: System.Generics.Defaults

class function TComparer<T>.Default: IComparer<T>;  

This method returns an instance of the default comparer for type T.

It is used by TArrayUtils whenever an optional comparer object or function is not provided by the user.

TEqualityComparer<T>.Default class method

Unit: System.Generics.Defaults

class function TEqualityComparer<T>.Default: IEqualityComparer<T>;  

This method returns an instance of the default equality comparer for type T.

It is used by TArrayUtils whenever an optional equality comparer object or function is not provided by the user.