亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
一区二区三区丝袜| 95精品视频在线| 国产白丝网站精品污在线入口| 91香蕉视频mp4| 日韩美女一区二区三区四区| 亚洲婷婷在线视频| 国产河南妇女毛片精品久久久| 欧美日韩一区二区三区在线| 日韩一区有码在线| 国产精品一区二区在线看| 欧美日本不卡视频| 亚洲欧美日韩一区| 成人午夜激情片| 精品第一国产综合精品aⅴ| 亚洲成人自拍网| 91黄色激情网站| 国产欧美精品一区aⅴ影院| 精品一区二区三区视频在线观看| 欧美吻胸吃奶大尺度电影| 中文字幕日韩一区| 99久久综合精品| 国产精品网曝门| 国产91精品精华液一区二区三区| 精品欧美一区二区三区精品久久| 日本最新不卡在线| 欧美日韩国产免费| 亚洲国产精品人人做人人爽| 日本精品视频一区二区三区| 综合在线观看色| 91麻豆文化传媒在线观看| 国产精品久久网站| av在线播放成人| 亚洲天堂a在线| 色偷偷88欧美精品久久久| 亚洲欧美在线视频| 91玉足脚交白嫩脚丫在线播放| 国产精品国产自产拍高清av | 性久久久久久久久久久久| 日本黄色一区二区| 亚洲国产视频一区| 欧美三级一区二区| 日韩av不卡一区二区| 欧美不卡视频一区| 国产91精品在线观看| 日韩毛片精品高清免费| 精品视频色一区| 亚洲一二三四在线| 日韩欧美亚洲国产另类| 国产精品综合二区| 国产精品久久久久久久久晋中 | 国产做a爰片久久毛片| 久久久久久**毛片大全| 成人免费黄色在线| 亚洲综合成人网| 91精品国产综合久久婷婷香蕉 | 欧美午夜精品久久久久久孕妇| 亚洲自拍偷拍麻豆| 欧美va亚洲va香蕉在线| 成人综合在线观看| 亚洲自拍偷拍网站| 欧美v日韩v国产v| 99精品视频中文字幕| 亚洲第一主播视频| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 欧美在线三级电影| 日韩成人精品在线| 国产精品理论片| 制服丝袜在线91| 豆国产96在线|亚洲| 日韩精品一区第一页| 中文字幕av一区二区三区高| 欧美视频在线一区二区三区| 国产麻豆欧美日韩一区| 亚洲激情图片小说视频| 欧美成人性福生活免费看| 色噜噜夜夜夜综合网| 国产在线视频一区二区三区| 一区二区在线观看免费视频播放| 日韩亚洲欧美在线| 在线观看av不卡| 成人高清免费在线播放| 日本女优在线视频一区二区| 综合色天天鬼久久鬼色| 久久男人中文字幕资源站| 欧美自拍偷拍午夜视频| 北岛玲一区二区三区四区| 久久精品国产一区二区三区免费看| 亚洲欧洲性图库| 久久亚洲二区三区| 欧美电影在线免费观看| 91在线云播放| 国产二区国产一区在线观看| 青青草一区二区三区| 亚洲综合视频网| 中文字幕中文字幕一区| www亚洲一区| 欧美一级在线视频| 欧美二区三区91| 欧美日韩黄色一区二区| 日本韩国欧美一区二区三区| 成人aa视频在线观看| 国产成人综合在线| 国产中文一区二区三区| 免费精品视频在线| 日日噜噜夜夜狠狠视频欧美人 | 中文字幕在线播放不卡一区| 国产亚洲综合性久久久影院| 欧美大黄免费观看| 日韩欧美你懂的| 欧美一卡二卡在线观看| 欧美日高清视频| 欧美日韩国产成人在线91| 欧美中文字幕一区| 欧美日韩视频一区二区| 欧美日韩二区三区| 日韩三级电影网址| 精品第一国产综合精品aⅴ| 久久青草欧美一区二区三区| 2024国产精品| 中国av一区二区三区| 久久精品视频在线免费观看| 国产欧美一区二区精品性色超碰 | 免费视频一区二区| 亚洲va在线va天堂| 美女视频一区在线观看| 久久精品国产久精国产爱| 国产一区在线观看麻豆| 国产成人啪免费观看软件| 国产.精品.日韩.另类.中文.在线.播放| 国精品**一区二区三区在线蜜桃| 国内精品国产成人| av亚洲精华国产精华精| 91福利国产精品| 欧美三级电影一区| 日韩美女主播在线视频一区二区三区| 日韩精品专区在线影院观看| 久久久美女毛片| 亚洲视频电影在线| 日韩激情一区二区| 韩国欧美国产1区| 成人av免费在线| 欧美日韩激情在线| 久久久久久97三级| 亚洲综合色噜噜狠狠| 麻豆91小视频| 色综合久久中文综合久久97| 91精品国产综合久久久久久久久久| 欧美成va人片在线观看| 最新日韩av在线| 人人精品人人爱| a4yy欧美一区二区三区| 欧美一区二区高清| 亚洲视频 欧洲视频| 美女脱光内衣内裤视频久久网站| 国产91丝袜在线播放| 7777精品伊人久久久大香线蕉 | 青青草成人在线观看| 99免费精品在线观看| 欧美一区二区高清| 一区二区三区丝袜| 国产激情一区二区三区四区 | 欧美无砖专区一中文字| 国产视频不卡一区| 日韩av高清在线观看| 99国产一区二区三精品乱码| 欧美videossexotv100| 一区二区三区四区在线播放| 韩国精品一区二区| 欧美日本乱大交xxxxx| 亚洲天堂成人在线观看| 国产高清无密码一区二区三区| 欧美性猛片aaaaaaa做受| 国产精品乱码一区二三区小蝌蚪| 奇米四色…亚洲| 91福利在线看| 亚洲视频你懂的| 国产69精品久久久久777| 欧美大片国产精品| 午夜精品在线视频一区| 色哟哟国产精品免费观看| 国产偷国产偷亚洲高清人白洁| 裸体一区二区三区| 欧美精品自拍偷拍动漫精品| 亚洲九九爱视频| 99国产欧美另类久久久精品 | 色综合天天综合狠狠| 欧美极品xxx| 国产精一品亚洲二区在线视频| 亚洲欧美韩国综合色| 成人午夜短视频| 国产女人18毛片水真多成人如厕 | 欧美精品乱码久久久久久| 亚洲男同1069视频| 成人免费视频一区二区| 久久久国产午夜精品| 色综合天天综合网天天看片| 国产精品乡下勾搭老头1| 亚洲一区二区欧美日韩| 欧美日本一区二区| 亚洲成人先锋电影|