zoukankan      html  css  js  c++  java
  • 泛型单元

    文章来自:http://interactiveasp.net/blogs/spgilmore/archive/2009/12/23/using-generics-in-delphi.aspx

    包含泛型的单元:Generics.Defaults, Generics.Collections, SysUtils.pas

    Here are the public declarations in Generics.Defaults.pas:

    Classes / Interfaces Description
    IComparer<T> Implements a compare function returning less-than, greater-than or equal-to.
    IEqualityComparer<T> Implements a compare function returning equal-to or not.
    TComparer<T> Abstract class for implementing IComparer<T>.
    TEqualityComparer<T> Abstract class for implementing IEqualityComparer<T>
    TSingletonImplementation Weak-reference implementation of TInterfacedObject.  Instances are not automatically freed.
    TDelegatedEqualityComparer<T> A comparer that takes a delegated comparison function and uses it to determine equality.
    TDelegatedComparer<T> A comparer that takes a delegated function to do the actual comparison.
    TCustomComparer<T> An abstract singleton class for comparison operations.
    TStringComparer Compares strings.
    Method prototypes / delegates  
    TComparison<T> A delegate method prototype for less-than, greater-than, or equal-to comparisons.
    TEqualityComparison<T> A delegate method prototype for equality comparisons.
    THasher<T> A delegate method prototype for getting the hash value of an object or value.
    Concrete Functions  
    function BobJenkinsHash(const Data;
    Len, InitData: Integer): Integer;
    Returns a hash from the given data.
    function BinaryCompare(const Left, Right: Pointer;
    Size: Integer): Integer;
    A method to compare binary data.  Does not match comparison prototypes, so must be used from a comparison class rather than pass as a delegated method.

    Here are the public declarations in Generics.Collections.pas:

    Classes / Interfaces Description
    TArray Contains no data, but provides methods for working with arrays.  Strangely, the class is not generic and the members are.  This can easily be confused with TArray<T>, which is in System.pas, which contains data and no methods.
    TEnumerator<T> Implements the iterator pattern on your data.
    TEnumerable<T> Returns an enumerator, allowing your class to be used in a For..In construct.
    TList<T> A generic collection or objects, records or primitives.
    TQueue<T> A generic queue (first in / last out) collection.
    TStack<T> A generic stack (first in / first out) collection.
    TPair<TKey, TValue> A structure containing two child members of disparate types.
    TDictionary<TKey, TValue> A searchable collection with lookup keys.
    TObjectList<T: class> A generic collection of objects (records and primitives not allowed).
    TObjectQueue<T: class> A generic queue of objects.
    TObjectStack<T: class> A generic stack of objects.
    TObjectDictionary<TKey, TValue> A generic collection of owned objects with lookup keys.
    Enums  
    TCollectionNotification Used in TCollectionNotifyEvent<>
    TDictionaryOwnerships Used by TObjectDictionary<>
    Method prototypes / delegates  
    TCollectionNotifyEvent<T> Used by various collections to implement an observer pattern.
    Concrete functions  
    InCircularRange  
    Type aliases  
    PObject Pointer to TObject.
    Exceptions  
    ENotsupportedException  

    Here are the pertinent declarations in SysUtils.pas:

    Method prototypes / delegates Description
    TProc A procedure with no parameters.
    TProc<T> A procedure with one generic parameter.
    TProc<T1, T2> A procedure with two generic parameters.
    TProc<T1, T2, T3> A procedure with three generic parameters.
    TProc<T1, T2, T3, T4> A procedure with four generic parameters.
    TFunc<TResult> A function with no parameters and a generic return type.
    TFunc<T, TResult> A function with one generic parameter and a generic return type.
    TFunc<T1, T2, TResult> A function with two generic parameters and a generic return type.
    TFunc<T1, T2, T3, TResult> A function with three generic parameters and a generic return type.
    TFunc<T1, T2, T3, T4, TResult> A function with four generic parameters and a generic return type.
    TPredicate<T> A function with one generic parameter and a boolean return type.  This is used by collections as a “filter” for elements.  Elements that are passed to a predicate function which return false are excluded from the result.
  • 相关阅读:
    2、词法分析--4、字面值--2、字符串拼接
    2、词法分析--3、标识符和关键字
    2、词法分析-- 1、行结构
    git本机服务器配置(四):git+TortoiseGit+gitblit配置本机服务器
    git本机服务器配置(三):Gitblit的安装
    git本机服务器配置(二):TortoiseGit的安装
    git本机服务器配置(一):git的安装
    python 中 dlib库的安装
    正向代理和方向代理的区别和使用
    php应用路径变量问题总结
  • 原文地址:https://www.cnblogs.com/wouldguan/p/2173370.html
Copyright © 2011-2022 走看看