zoukankan      html  css  js  c++  java
  • Delphi中GUID相等检查中经典指针应用

    type
      PGUID = ^TGUID;
      TGUID = packed record
        D1: LongWord;
        D2: Word;
        D3: Word;
        D4: array[0..7] of Byte;
        class operator Equal(const Left, Right: TGUID): Boolean;
        class operator NotEqual(const Left, Right: TGUID): Boolean;
        class function Empty: TGUID; static;
      end;
     
     IntegerArray  = array[0..$effffff] of Integer;
      PIntegerArray = ^IntegerArray;
    
    function IsEqualGUID(const Guid1, Guid2: TGUID): Boolean;
    var
      a, b: PIntegerArray;
    begin
      a := PIntegerArray(@Guid1);
      b := PIntegerArray(@Guid2);
      Result := (a^[0] = b^[0]) and (a^[1] = b^[1]) and (a^[2] = b^[2]) and (a^[3] = b^[3]);
    end;
    

    遗留问题:Word 怎么转换成Ineger的? D2,D3:Word

    @Guid1 内存存储结构是什么样的? 0xffff 0xff 0xff 0xff 转到PintegerArray后是什么样的? a^[1]=0xff 还是a^[1]=0xffff 为什么?
  • 相关阅读:
    hrbust 1558 小背包(简单01背包)水坑
    hrbust 1174泉水(DFS深度优先搜索)
    HDU 1115
    HDU 4273
    HDU 2912
    POJ 3528
    HDU 1912
    HDU 4741
    HDU 4617
    POJ 1755
  • 原文地址:https://www.cnblogs.com/ZhouXiHong/p/4371823.html
Copyright © 2011-2022 走看看