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.
  • 相关阅读:
    2020软件工程最后一次作业
    常用的10种算法

    赫夫曼编码
    哈希表(散列)
    查找算法
    排序算法
    递归

    软件工程最后一次作业
  • 原文地址:https://www.cnblogs.com/wouldguan/p/2173370.html
Copyright © 2011-2022 走看看