亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hwstrhashmap.pas

?? 用于Delphi程序中嵌入公式解析
?? PAS
?? 第 1 頁 / 共 3 頁
字號:
{******************************************************************************}
{                                                                              }
{ Project JEDI Code Library (JCL)                                              }
{                                                                              }
{ The contents of this file are subject to the Mozilla Public License Version  }
{ 1.1 (the "License"); you may not use this file except in compliance with the }
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
{                                                                              }
{ Software distributed under the License is distributed on an "AS IS" basis,   }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License.    }
{                                                                              }
{ The Original Code is JclStrHashMap.pas.                                      }
{                                                                              }
{ The Initial Developer of the Original Code is documented in the accompanying }
{ help file JCL.chm. Portions created by these individuals are Copyright (C)   }
{ 2001 of these individuals.                                                   }
{                                                                              }
{ Description: String-pointer associative map.                                 }
{ Unit Owner: Barry Kelly.                                                     }
{                                                                              }
{******************************************************************************}
{                                                                              }
{ This unit contains a string-pointer associative map. It works by hashing     }
{ the added strings using a passed-in traits object.                           }
{                                                                              }
{ Unit owner: Barry Kelly                                                      }
{ Last modified: June 6, 2001                                                  }
{                                                                              }
{******************************************************************************}

{ This unit contains the implementation of a string / pointer associative
  map. }
  
{ Charmer description:
  為TStringHashMap添加兩個屬性Items和ItemsName,用于通過通常的Items方式訪問
  表項。注意:通過Index訪問數據的速度慢于使用Name }
unit hwStrHashMap;

{$INCLUDE JCL.INC}

interface

uses SysUtils, JclBase, JclResources;

type
  { Brief: The error exception class used by TStringhashMap. }
  //EhwStringHashMapError = class(EJclError);
  EhwStringHashMapError = class(EJclError);
  { Brief: The type of the return value for hashing functions. }
  THashValue = Cardinal;

type
  { Brief: An abstract class describing the interface for traits classes.
    Description:
      The desired behaviour of TStringHashMap for case sensitive and
      case insensitive maps is different. This class describes the
      interface through which user code can communicate to TStringHashMap
      how string keys added should be treated. Concrete instances are
      returned by the CaseSensitiveTraits and CaseInsensitiveTraits
      functions.

      See also: TCaseSensitiveTraits, TCaseInsensitiveTraits }
  TStringHashMapTraits = class
  public
    { Brief: Returns the hash value of the string s. }
    function Hash(const s: string): Cardinal; virtual; abstract;
    { Brief: Returns a negative integer if l is before r, a positive
      integer if r is before l, and zero if they are equal; all comparisons
      being lexicographical, i.e. not necessarily based on the ordinal
      values of the characters, but may be case insensitive, for example. }
    function Compare(const l, r: string): Integer; virtual; abstract;
  end;

{ Brief: A utility function returning an instance of TCaseSensitiveTraits. }
function CaseSensitiveTraits: TStringHashMapTraits;
{ Brief: A utility function returning an instance of TCaseInsensitiveTraits. }
function CaseInsensitiveTraits: TStringHashMapTraits;

type
  { Brief: The type of the parameter to TStringHashMap.Iterate.
    Description:
      * AUserData:
        The same parameter as was passed to the Iterate method.
      * AStr:
        The value of the string part of the current key.
      * APtr:
        The value of the pointer part of the current key.
    Should return True to continue iterating, or False to
    stop iterating and return to whatever called the Iterate method. }
  TIterateFunc = function(AUserData: Pointer; const AStr: string;
    var APtr: Pointer): Boolean;

  { Brief: The type of the parameter to TStringHashMap.IterateMethod.
    Description:
      These are the meanings of the arguments:<p>
      AUserData:
        The same parameter as was passed to the IterateMethod method.
      AStr:
        The value of the string part of the current key.
      APtr:
        The value of the pointer part of the current key.

      <p>Return value: Should return True to continue iterating, or False to
        stop iterating and return to whatever called the IterateMethod method. }
  TIterateMethod = function(AUserData: Pointer; const AStr: string;
    var APtr: Pointer): Boolean of object;

  { Brief: Pointer to a pointer to a THashNode record. }
  PPHashNode = ^PHashNode;
  { Brief: Pointer to a THashNode record. }
  PHashNode = ^THashNode;
  { Brief: The internal storage record used by TStringHashMap. }
  THashNode = record
    Str: string;
    Ptr: Pointer;
    Left: PHashNode;
    Right: PHashNode;
  end;

  { Internal iterate function pointer type used by the protected
    TStringHashMap.NodeIterate method. }
  TNodeIterateFunc = procedure(AUserData: Pointer; ANode: PPHashNode);

  { Brief: Pointer to a THashArray. }
  PHashArray = ^THashArray;
  { Brief: THashArray is the type of the array used for internal storage in
    TStringHashMap. }
  THashArray = array[0..MaxInt div SizeOf(PHashNode) - 1] of PHashNode;

  { Brief: TStringHashMap is a string-pointer associative array.
    Description:
      TStringHashMap is a string-pointer associative array. It uses a
      hash table for its implementation, which has several ramifications
      for its behaviour:
        * Lookup by string takes a constant time, i.e. if the map is big
          enough it takes just as long to find an item from 10 as from
          10 million (ignoring cache and paging effects).
        * Items are unordered. An iteration of all the items using the
          Iterate or IterateMethod methods won't go through all the items
          in any order that has meaning, i.e. the ordering is essentially
          random. }
  TStringHashMap = class
  private
    FHashSize: Cardinal;
    FCount: Cardinal;
    FList: PHashArray;
    FLeftDelete: Boolean;
    FTraits: TStringHashMapTraits;

    function IterateNode(ANode: PHashNode; AUserData: Pointer;
      AIterateFunc: TIterateFunc): Boolean;
    function IterateMethodNode(ANode: PHashNode; AUserData: Pointer;
      AIterateMethod: TIterateMethod): Boolean;
    procedure NodeIterate(ANode: PPHashNode; AUserData: Pointer;
      AIterateFunc: TNodeIterateFunc);
    procedure SetHashSize(AHashSize: Cardinal);
    procedure DeleteNodes(var q: PHashNode);
    procedure DeleteNode(var q: PHashNode);
    { Charmer Ext.... }
    function GetItems(Index: Cardinal): Pointer;
    function GetItemsName(Index: Cardinal): string;
  protected
    { Brief: A helper method used by the public methods.

      Parameters:
        s: The string key of the node to find.

      Returns:
        The location of the pointer to the node corresponding to s, if
        s is in the hash table. If s isn't in the table, then it will
        return the location of the pointer (= nil) which must be set
        in order to add s correctly to the table.

      Description:
        Returns, using double indirection, the node corresponding to the
        parameter. The double indirection allows internal implementation
        methods to both search and add using only one search through the
        table. }
    function FindNode(const s: string): PPHashNode;

    {@@$TStringHashMap_Alloc
      <TITLE Customizing TStringHashMap's node allocation strategy.>
      You can customize the way TStringHashMap allocates nodes, to avoid the
      overhead of millions of calls to New, by overriding the AllocNode
      and FreeNode methods. }

    { <GROUP $TStringHashMap_Alloc>
      <TITLE Allocating a node>
      Brief: Allocates a node.
      Returns: A pointer to a newly allocated node, with the Left and Right
        members set to nil. }
    function AllocNode: PHashNode; virtual;
    { <GROUP $TStringHashMap_Alloc>
      <TITLE Freeing a node>
      Brief: Frees a node.
      Parameters:
        ANode: The node to free. }
    procedure FreeNode(ANode: PHashNode); virtual;

    { Brief: Data property getter.
      Parameters:
        s: The key of the node to find.
      Returns:
        The value of the pointer if the node exists, or nil otherwise. }
    function GetData(const s: string): Pointer;
    { Brief: Data property setter.
      Parameters:
        s: The key of the node to set.
        p: The data to set the node's data to.
      Description:
        SetData will create a new node if none exists with key s. }
    procedure SetData(const s: string; p: Pointer);
  public
    { Brief: Constructs a new TStringHashMap instance.
      Parameters:
        ATraits:
          An instance of a descendant of TStringHashMapTraits. This object
          describes how the hash map will hash and compare string values.
        AHashSize:
          An initial size for the internal hash lookup table. This doesn't
          limit the amount of items the hash can hold; it just affects the
          speed of operations on the hash map. See the HashSize property for
          more info.
      Note: AHashSize should <b>not</b> be a power of 2. Use a power of 2
        minus 1, or a prime number. }
    constructor Create(ATraits: TStringHashMapTraits; AHashSize: Cardinal);

    { Brief: Destroys the instance. Call Free instead of Destroy. }
    destructor Destroy; override;

    { public methods }

    { Brief: Adds an association to the map.
      Parameters:
        s: The key to add.
        p: The data to add. It is an untyped constant to avoid typecasting
          issues, and to make code using the map more readable. It should
          be a 4-byte data type, like Integer or Pointer, or some object
          reference. }
    procedure Add(const s: string; const p{: Pointer});

    { Brief: Removes an association from the map.
      Parameters:
        s: The string value of the association to remove.
      Returns:
        The data field of the assocation.
      Description:
        The Remove method isn't as fast at removing items as Clear is; that
        is, calling Remove for every key in the hash will be quite a bit
        slower than calling Clear. The method returns the data field so that
        compact code can be written. See the example for sample usage.

        EhwStringHashMapError will be raised if the item isn't found.
      Example:
        This example demonstrates how the Remove method's return value can
        be used.
        <code>
        var
          myMap: TStringHashMap;
          // ...
          TObject(myMap.Remove('SomeItem')).Free;
        </code> }
    function Remove(const s: string): Pointer;

    { Brief: Removes <b>every</b> instance of p as a data field from the map.
      Parameters:
        p: The data to item. }
    procedure RemoveData(const p{: Pointer});

    { Brief: Iterates through associations in the map.
      Parameters:
        AUserData: A pointer parameter passed through untouched to the
          iterator function.
        AIterateFunc: A function pointer called for every assocation in
          the map; it should return False if it wants to prematurely stop
          the iteration.
      See Also: IterateMethod }
    procedure Iterate(AUserData: Pointer; AIterateFunc: TIterateFunc);

    { Brief: Iterates through associations in the map.
      Parameters:
        AUserData: A pointer parameter passed through untouched to the
          iterator method.
        AIterateMethod: A method pointer called for every assocation in
          the map; it should return False if it wants to prematurely stop
          the iteration.
      See Also: Iterate }
    procedure IterateMethod(AUserData: Pointer; AIterateMethod: TIterateMethod);

    { Brief: Checks if the map has an association with a string key.
      Parameters:
        s: The key to search for.
      Returns:
        True if found, False if there is no assocation with key s in the
          map. }
    function Has(const s: string): Boolean;

    { Brief: Finds the data part of an association corresponding to a string
        key.
      Parameters:
        s: The string key to find.
        p: A reference to a pointer which will be updated if the assocation
          is found. If the assocation isn't found, the pointer isn't touched.
          That is, it won't automatically be set to nil.
      Returns:
        True if the key was found, False otherwise. }
    function Find(const s: string; var p{: Pointer}): Boolean;

    { Brief: Finds the string key for a data value.
      Parameters:
        p: The data value to find.
        s: A reference to the string key to set if found.
      Returns:
        True if found, false otherwise.
      Description:
        FindData will find the first association in the map with a data
        field equal to p. However, the order of the search has no meaning;
        if there are multiple instances of p in the node, the key returned
        is not in any particular order. }
    function FindData(const p{: Pointer}; var s: string): Boolean;

    { Brief: Clears the map of all associations. }
    procedure Clear;

    { Brief: The number of assocations stored in the map. }
    property Count: Cardinal read FCount;

    { Brief: Allows access to the map like an array looked up by string.
      Description:
        This is the default property, so it needn't be specified directly.
        If the key corresponding to the string isn't found, an assocation
        is added if setting, but isn't added if getting. Reading from the
        map with a key not in the map will return nil.
      Example:
        Demonstrates use of the TStringHashMap.Data property.
        <code>
        var
          myMap: TStringHashMap;
          // ...
          myMap['this'] := Self;
          if myMap['something'] = nil then
            // 'something' not found
        </code> }
    property Data[const s: string]: Pointer read GetData write SetData; default;
    { Brief: Returns the traits object being used by the map. }
    property Traits: TStringHashMapTraits read FTraits;
    { Brief: The internal hash table size.
      Description:
        The hash table size affects all operations on the hash map. For maps
        designed to work with large numbers of assocations, the table should
        be correspondingly larger.
      Note: Don't change the value of this property too often, as it will
        force all items in the table to be rehashed, and this can take
        some time. }
    property HashSize: Cardinal read FHashSize write SetHashSize;
    { Charmer Ext.... }
    property Items[Index: Cardinal]: Pointer read GetItems;
    property ItemsName[Index: Cardinal]: string read GetItemsName;
  end;

{ str=case sensitive, text=case insensitive }

{ Brief: Case sensitive hash of string s. }
function StrHash(const s: string): THashValue;
{ Brief: Case insensitive hash of string s. }
function TextHash(const s: string): THashValue;
{ Brief: A utility function which computes a hash a buffer.
  Parameters:
    AValue: A reference to the buffer to compute a hash value for.
    ASize: The size of the buffer. Use SizeOf where possible. }
function DataHash(var AValue; ASize: Cardinal): THashValue;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜视频久久久久久| 亚洲视频在线观看三级| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 欧美视频一区二区三区| 欧美在线一二三| 亚洲成av人片在线观看无码| 欧美日韩视频一区二区| 日韩av电影一区| 精品国产123| av午夜一区麻豆| 亚洲一线二线三线视频| 在线播放91灌醉迷j高跟美女 | 在线观看免费视频综合| 在线日韩av片| 91精品欧美一区二区三区综合在| 欧美成人a在线| 久久久久国色av免费看影院| 欧美日韩成人在线| 精品美女一区二区| 中文字幕永久在线不卡| 亚洲免费视频成人| 精品一区二区三区日韩| 日韩成人一级大片| 91在线免费播放| 777奇米成人网| 中文字幕色av一区二区三区| 视频一区国产视频| 成人av动漫网站| 51精品视频一区二区三区| 精品久久久影院| 亚洲综合色区另类av| 国产一区二区三区免费看| 色综合久久66| 欧美国产一区二区在线观看| 日韩av中文在线观看| 亚洲国产一区二区视频| 在线成人av网站| 久久久99精品免费观看不卡| 国产欧美一区二区在线观看| 有码一区二区三区| 一级精品视频在线观看宜春院 | 欧美久久久久免费| 精品国产91洋老外米糕| 95精品视频在线| 免费久久99精品国产| 最新国产精品久久精品| 欧美一区二区在线不卡| 成人网在线免费视频| 日本aⅴ免费视频一区二区三区| 91豆麻精品91久久久久久| 久久综合狠狠综合| 国产在线精品免费| 国产精品毛片a∨一区二区三区| 激情偷乱视频一区二区三区| 欧美精品免费视频| 亚洲一区二区在线视频| 国产一区啦啦啦在线观看| 日韩精品一区二| 国产一区二区三区最好精华液| 日韩亚洲国产中文字幕欧美| 日韩黄色一级片| 国产亚洲短视频| 色综合欧美在线| 天天综合网 天天综合色| 欧美性高清videossexo| 奇米精品一区二区三区在线观看一| 日韩亚洲国产中文字幕欧美| 国产乱子伦视频一区二区三区 | 亚洲精品一区二区三区蜜桃下载| 日韩成人一级大片| 国产精品毛片久久久久久久| 在线亚洲免费视频| 久久91精品国产91久久小草 | 精品国产成人系列| 欧美系列日韩一区| 伦理电影国产精品| 开心九九激情九九欧美日韩精美视频电影| 欧美三级在线视频| 中文字幕亚洲一区二区va在线| 成人午夜精品在线| 日韩精彩视频在线观看| 久久成人精品无人区| 欧美在线观看视频在线| 麻豆久久一区二区| 亚洲色图欧美偷拍| 亚洲精品免费电影| 一区二区三区中文字幕电影| 亚洲欧美日韩中文字幕一区二区三区 | 精品剧情在线观看| 欧美videos大乳护士334| 欧美成人国产一区二区| 久久久美女艺术照精彩视频福利播放| 精品国产一区二区国模嫣然| 欧美精品一区二区三区蜜桃视频| 精品国产成人在线影院| 国产日产亚洲精品系列| 日本一区二区三区免费乱视频| 国产精品久久久久久久浪潮网站| 亚洲色图欧洲色图婷婷| 舔着乳尖日韩一区| 国产美女娇喘av呻吟久久| 国产剧情一区二区| 99精品久久久久久| 欧美三级电影在线看| 日韩视频永久免费| 欧美国产97人人爽人人喊| 一区二区三区在线免费观看| 天天做天天摸天天爽国产一区| 激情国产一区二区| 91亚洲精品久久久蜜桃网站| 欧美日韩国产天堂| 久久无码av三级| 亚洲日本一区二区| 日韩黄色小视频| jiyouzz国产精品久久| 欧美日韩一区国产| 国产视频一区二区三区在线观看| 亚洲精品成人少妇| 精品一二三四区| 91同城在线观看| 精品奇米国产一区二区三区| 亚洲视频在线观看一区| 美女免费视频一区| 色老汉一区二区三区| 精品99久久久久久| 亚洲成人久久影院| 成人国产亚洲欧美成人综合网| 欧美日韩中字一区| 国产精品色噜噜| 男人的天堂久久精品| 91免费观看视频| 久久久久久一级片| 日韩精彩视频在线观看| 91色乱码一区二区三区| 久久影院视频免费| 日韩国产一区二| 91视频免费观看| 中文在线资源观看网站视频免费不卡| 蜜芽一区二区三区| 欧美亚洲综合网| 中文字幕一区二区三区四区不卡| 国产中文字幕精品| 日韩亚洲欧美在线| 日本欧美在线观看| 欧美日韩一二三区| 亚洲欧美偷拍三级| 成人综合在线网站| 久久久久亚洲综合| 国内一区二区视频| 精品国产乱码久久久久久闺蜜 | 91色porny蝌蚪| 日本精品一区二区三区四区的功能| 91丨九色丨尤物| 日本一二三四高清不卡| 狠狠狠色丁香婷婷综合久久五月| 欧美日韩精品久久久| 亚洲精品久久7777| 丁香亚洲综合激情啪啪综合| 久久久久青草大香线综合精品| 九九精品视频在线看| 欧美成人精精品一区二区频| 美女一区二区在线观看| 91麻豆精品国产| 免费三级欧美电影| 欧美tk—视频vk| 国内精品视频666| 精品久久久久99| 国产在线精品不卡| 久久久久久9999| 成人一区二区三区中文字幕| 国产日韩一级二级三级| 国产精品18久久久久久久久久久久| 久久影视一区二区| 国产91丝袜在线播放0| 国产精品美女久久福利网站| 91在线观看一区二区| 亚洲精品高清视频在线观看| 欧美三区免费完整视频在线观看| 午夜激情一区二区| 欧美不卡一二三| 国产高清精品网站| 成人欧美一区二区三区白人| 9l国产精品久久久久麻豆| 亚洲精品国产精品乱码不99| 欧美日韩精品系列| 美女爽到高潮91| 中国av一区二区三区| 色94色欧美sute亚洲线路二 | 欧美日韩午夜影院| 理论片日本一区| 中文字幕的久久| 在线精品亚洲一区二区不卡| 午夜精品久久久久久久久久| 欧美白人最猛性xxxxx69交| 粗大黑人巨茎大战欧美成人| 成人福利视频在线| 亚洲视频1区2区| 日韩一级大片在线观看| 丰满岳乱妇一区二区三区| 一区二区三区高清在线|